An Indian resident buying a US stock generates US-source dividend income. The US says: that's our income, we'll withhold. India says: you're our resident, your worldwide income is ours. Without a treaty, both rules apply and you pay twice.
The India-US Double Taxation Avoidance Agreement (DTAA) reconciles this. The US gets to withhold dividends at a treaty rate (25% for individuals, 15% in some structures). India taxes the same dividend as part of your global income but gives you a Foreign Tax Credit for the US withholding. Net effect: you pay the higher of the two rates, not the sum.