Americans either didn’t want or didn’t qualify for these jobs, no employer goes through the visa process to stick it to Americans, it’s a giant pain in the ass.
Americans didn't want those jobs at the salary they were offering. That's the kicker.
The visa process may be a pain. But with a company like Tata to help you with it or do it for you, you can end up paying that H1B worker MUCH less than you would an American. And because their H1B is tied to their employment they won't rock the boat because getting fired means having to leave the USA.