Purchasing Russian missiles have risks of inviting US sanctions.
Since India is officially a US ally, Why is India purchasing S-400 rather than the US-made missiles (Patriot or David's Sling or THAAD)?
If tech-transfer was the issue, S-400 doesn't come with a tech-transfer. Patriot and THAAD may also deny tech-transfer. In that case, Israel's David's Sling might have been a better option.
P.S. My personal opinion is, India was probably trying to (1) avoid lengthy negotiation, (2) engage Russia with defense deals so that they don't lean or sell arms to Pakistan.