BANGALORE, India—Software engineer Anshul Goel graduated from college in 2013. In the 2½ years since then, the 24-year-old has switched jobs three times, jumping from one Indian tech company to another, and doubled his salary.

Mr. Goel, who specializes in writing code that e-commerce startups and others use to predict customer behavior, says he is deluged with emails from headhunters. “My mailbox is full of them,” he said. “And it’s not only me.”

Indian...