The answer is probably pretty universal, but I'm in the United States. If I have a broker investing money on my behalf or if I invest my money myself in stocks or mutual funds (what's the general term for these sorts of things?) via, say, Charles Schwab, how do my taxes get paid? Does the brokerage automatically send Uncle Sam his cut or do I have to send the IRS a check?
In the US, capital gains taxes aren't levied on individual transactions - they're aggregated for the entire calendar year. Normally taxes aren't withheld from brokerage activity unless you are doing something like withdrawing funds from an IRA, where the withdrawal is taxed like normal income. One reason for not withholding at the transaction level is that capital gains can be offset by losses, and since the brokerage won't credit you tax for losses, it would usually lead to too much over-withholding. Plus many investors will have thousands of transaction, which would be an additional burden on the brokerages to withhold properly.
When you file your taxes after the year is over, all of your capital gains and losses are netted (based on short- or long-term gains) and added to your overall tax liability. Depending on how much tax you owe and how much was withheld from other sources (e.g. your salary) you will either have to pay additional tax or get a refund.
If you only have income from trading securities you probably will want to pay estimated taxes quarterly. That way you can avoid any underpayment penalties. You'll probably also want to hire a CPA to do that for you :)
You don't pay taxes when you or your broker invests money on your behalf. Taxes are due when you sell investments and there are capital gains. You are responsible for making the appropriate tax payments to the IRS.
In the U.S. investors receive the full amount of dividends received from American companies. However, many foreign governments withhold taxes on dividends from companies in their jurisdiction.