The ratio of the elements is the result of the sharing of electrons determined by the electron configuration of the elements.
The Compound is often named by the ratio of the elements. This indicates that the ratio of the elements in a compound can not change without changing the compound.
For example Carbon Monoxide has a ratio of one Carbon to one Oxygen. mono means one so one Oxygen.
Carbon Dioxide has a ratio of one Carbon to two Oxygen atoms.
di mean two so two Oxygens.
These two compounds of Carbon and Oxygen are different not only in their names, and formulas but also in their chemical properties.
So yes a compound will always have the same ratio of elements