My guess is that the company in question is not hiring H1-B workers, but outsourcing their IT department to another company that happens to employ H1-B workers. It's not illegal to outsource.
Think of a company that manufactures jeans and, in doing so, also manufactures rivets and buttons. They decide to have those rivets and buttons manufactured overseas to save money. As part of the outsourcing process, the company sends some US-based foreign workers to learn the button making process and then manage, from the US, the overseas manufacturing process. These employees are H1-B because they were brought, by the overseas manufacturer, to the US. They possess unique skills such as the ability to learn the manufacturing process AND the ability to communicate that process to the overseas plant in the native language of those plant workers. They also are able to manage the process from afar in the native language of the plant while communicating important details to the maker of jeans in English.
This same thing happens in IT - only the manufactured product is software.
I'm commenting on whether this is right or wrong, but just noting that I can see how companies get away with it. IT workers are now dealing with what factory workers dealt with decades ago.