When teaching beginners, usually non-stoichiometric chemical compounds are ignored. The reality is more complex than what they teach undergraduates and high school students. One important point about chemistry is that it is the study of atoms (mostly of the "naturally occurring" 92 elements) and their bonding and reactions.
The ideas of indivisible units (atoms) and shapes of molecules (geometry) are foundational in the science. An added confusion is that atoms (and molecules) are too small to count (or even to weigh, except with very expensive equipment in very special conditions). So we invented a number (similar to the number "dozen", except much much much bigger) and use Avogadro's Number as the count of the defined quantity of a "mole". We can do almost all (but not quite all) chemistry by considering one atom or molecule or one mole of atoms or molecules as being what is represented in a chemical equation A + B → C + D.
When we're talking about doing lab experiments, our only means to measure quantities is not to count atoms but to weigh them - large numbers of them. So, most chemistry is done in the lab using moles, not indivisible units (atoms or molecules). This works out pretty well.
Usually, the average isotopic composition is accurate enough so that 1.0000 moles of carbon weighs the same here or in Beijing. (In reality, the exact mass of 1 mole of C depends on its source: the ratio of 12C to 13C varies between C found in limestone, in plants, in seawater and in the atmosphere (slightly). but the kind of accuracy/ precision we generally work at in the lab allows us to ignore these fine points). Average atomic weight is good enough. Since this is so, for stoichiometric compounds the ratio of carbon (by mass) in C2H6 (ethane) to C7H5N3O6 (trinitrotoluene, T.N.T.) is 2:7 (or 7:2) a ratio of "small integers".
The small whole number thing follows directly from the atomic weights being (nearly) constant and the stoichiometric nature of the compounds being considered. Dealing with more complicated situations which don't follow that "law" just usually isn't done in beginning chemistry.
In science, almost everything you learn is wrong. Wrong in the sense that it is only approximately correct. So, your knowledge will be like an onion, with a layer under a layer under a layer.
For this law, all it is really saying (using atom's mass rather than their count) is that the counts will be in ratios of small integers. Given a set of atomic weights, you can't give me an example of their mass ratios violating the law. Because for element Z, all chemical equations and formulae, whether expressed in atoms of Z or in moles of Z will be in multiples of either it's count (which is pretty useless in the laboratory or in the real world) or the atomic weight ( we can typically weigh amounts to 4 decimal digits precision, and 6 isn't uncommon and 8 is possible). So that means mass (weight) is very useful for determining the counts (hence the formula).
Looking at the periodic table, you'll notice that (in a good one) the atomic weights do NOT all have the same precision. The reason that C is 12.011 but He is 4.0026 and Li 6.94 is not because we can't determine the weight (mass) accurately, but because it varies depending on the source of the element.
The mass of each atom depends on four things: its atomic number (which tells you the number of electrons and protons present in the (electrically neutral) atom), the number of neutrons, the binding energy (remember E = mc² or rearranging m = E/c² where m is binding mass and E is binding energy of the quark-gluon cloud which makes up the nucleus), and any kinetic or potential energy due to its speed or location in a field.
So, no, you can't calculate an element's average atomic weight by simply multiplying the number of neutrons by a factor and the number of protons by a factor and adding them up (although it's not a terrible approximation for nonrelativistic atoms).
There are several examples of non-stoichiometric materials. Metamaterials, which are (usually) built up of layers of atoms, so the atom count isn't a useful measure of the material. Polymers (where you almost always have a range of molecular sizes, so that the typical formula of AxBy where x and y can be any rational number since a polymer is a distribution of molecules of different sizes, it isn't quite what a purist would say is a chemical compound, but most of us would accept it as one especially for large x + y without many (or any) small mw polymer molecules present.
And finally there are many many examples of substitution compounds, consider electronics. The "brains" of a computer is made of billions of transistors made by adding very small amounts (doping) of one element to another. Silicon chips, for instance, would be worthless without doping, but the amount of dopant is almost never a small integer SiMx where x almost never an integer, (and M is generally a group 13 or 15 element.)