If I don't own the stock I am investing in, like in a CFD, then how do I make money? Where does the money I am investing go to, and where does the money I make come from? And what happens to the person who actually owns the stock or financial instrument that I am investing in?
What is being described in Longson's answer, though helpful, is perhaps more similar to a financial spread bet. Exactly like a bookmaker, the provider of a spread bet takes the other side of the bet, and is counter party to your "trade".
A CFD is also a bet between two parties. Now, if the CFD provider uses a market maker model, then this is exactly the same as with a spread bet and the provider is the counter party. However, if the provider uses a direct market access model then the counter party to your contract is another CFD trader, and the provider is just acting as an intermediary to bring you together (basically doing the job of both a brokerage and an exchange).
A CFD entered into through a direct market access provider is in many ways similar to a Futures contract. Critically though, the contract is traded 'over-the-counter' and not on any centralized and regulated exchange. This is the reason that CFDs are not permitted in the US - the providers are not authorized as exchanges.
Whichever model your CFD provider uses, it is best to think of the contract as a 'bet' on the future price movements of the underlying stock or commodity, in much the same way as with any other derivative instrument such as futures, forwards, swaps, or options.
Finally, note that because you don't actually own the underlying stock (just as Longson has highlighted) you won't be entitled to any of the additional benefits that can come with ownership of a stock, such as dividend payments or the right to attend shareholder meetings.
RESPONSE TO QUESTION
So if I understand correctly, the money gained through a direct market access model comes from other investors in the same CFD who happened to have invested in the "wrong" direction the asset was presumed to take. What happens then, if no one is betting in the opposite direction of my investment.
Your understanding is correct. If literally nobody is betting in the opposite direction to you, then you will not be able to trade. This is true for any derivative market; if suddenly every single buyer were to remove their bids from the S&P futures, then no seller would be able to sell. This is a very extreme scenario, as the S&P futures market is incredibly liquid (loads of buyers and sellers at all times).
However, if something like this does happen (the flash crash of 2010, for example), then the centralized futures exchanges such as the CME have safeguards in place - the market become locked-limit so that it can only fall so far, there may be no buyers below the lock limit price, but the market cannot fall through it. CFD providers are not obliged to provide such safeguards, which is why regulators in the US don't permit them to operate. It may be the case that if you're trying to buy a CFD for a thinly traded and ill-liquid stock there will be no seller available. One possibility is that the provider will offer a 'hybrid' model, and in the absence of an independent counter party they will take the opposite side of your bet, and then offset their risk by taking an opposing position in the underlying stock.
A CFD is like a bet. Bookies don't own horses or racetracks but you still pay them and they pay you if the horses win.
If you buy a CFD the money goes to the firm you bought it from and if the stock price changes in your favour, they will pay you. However, if it goes against you they may ask you for more money than you originally invested to cover your losses.
Constacts for difference are derivatives, i.e. you gain on the change in the price or delta of something rather than on its absolute value. Someone bets one way and is matched with someone (or perhaps more than one) betting the other way. Both parties are bound by the contract to pay or be payed on the outcome. One will win and the other will necessarily lose.
It's similar in concept to a spread bet, although spread bets often have a fixed timescale whereas CFDs do not and CFDs generally operate via the payment of a commission rather than via charges included in the spread. There's more information on both CFDs and spread betting here
If somone has a lot of CFDs that might affect the stock price if it's known about as others may buy/sell real stock to either make the CFD pay or may it not pay depending on whether they think they can make money on it. Otherwise CFDs don't have much of an effect on stock prices.
1) You make money trading on the difference between the current security price and its value at the end of the deal. Under cfd, a seller abides to pay a buyer the difference between the current security price and its value at the end of the deal. The opposite is true if the difference is negative.
2) You invest money in buying CFDs on different assets (for example Apple stock)
3) The contract between you and the broker does not apply in any way the person who actually owns the stock or financial instrument that I am investing in
Here is a good guide https://capital.com/cfd-trading-explained if there are questions left