You seem to be genuinely curious, which is commendable.
>Will that apply to every law in society or just to H1B laws?
The H1B laws are harder to enforce than most laws -- or so it would seem to me -- because the question of whether there are Americans that are able to do a particular job at a particular workplace depends on many fiddly details that only the managers of the particular workplace (the prospective defendant in any enforcement action) would know.
When lawyers working on Capitol Hill are serious about stamping out a behavior, they write laws that are easy to enforce (unambiguous, not relying much on human judgment). Something as vague as, "as long as there are no Americans qualified to do the job," suggests that whoever wrote that just wants to reassure critics of the H1B program without caring much whether H1B workers actually displace American workers.
This is the lump of labor fallacy. People are both consumers and laborers; by bringing someone new into a labor market you marginally decrease demand for their skill set but you also marginally increase demand for all other labor. If H1-B visa holders all worked in the same industry, it could conceivably lower wages in that industry but they don't. They work in everything from healthcare, to IT, to education.