Is it possible to accidentally put too much into a Roth IRA? Suppose I have setup direct deposit to contribute $5500 annually to a Vanguard fund, but my math was off and I contributed $6000. What would happen to the extra cash? Would it still go into the fund? Or perhaps I earned some special dividend, pushing contributions over $5500. Would I be taxed on the dividend exceeding $5500?
Extra contribution above your limit will be taxed flat 6% a year until you withdraw it (unless you make the withdrawal before the closest Tax Day), in addition to the (ordinary) income tax on all the gains.
The limits are for the contributions, not earnings. What you earn inside the account doesn't affect your contribution limits.
Fairmark.com notes what the taxes and penalties would be in the case of excess contributions which can happen. These may change but you would have issues as there are forms filed with the IRS from the custodian of your Roth IRA.
Cash is what goes into a Roth IRA and any dividends or capital gains in the account aren't considered contributions. Thus, it would be money coming out of a bank account rather than moving monies around that would be how one would have excess contributions.