A stock is a share of ownership in a corporation - buying a stock means buying a piece of ownership in a corporation. However, there's more to know than just this...
Shares vs. Stocks
If you want to speak properly, there's no such thing as stocks - there is the "capital stock" of a corporation and that capital stock is divided into "shares" that you can buy and own. Those shares represent little pieces of equity in the firm - they represent ownership of a small piece of the firm.
In popular usage, however, the term "stocks" are often used in place of "shares" - we can say that we own "stocks" instead of "shares." It's ok to use the term this way because most people will understand you and most people use it this way, although it's a good idea to understand the proper way the term should be used.
What does a share (or stock) represent?
We said above that a share represents equity ownership in a corporation. What this means is that when you buy a share (or a stock), you are literally buying a piece of a corporation.
For example, if there are 1 million shares that are publically traded and you buy 1000 shares of the operation, you now own one-thousandth (1/1000th) of the corporation.
But, what do you actually own when you own shares of a corporation? You literally own piece of everything the corporation owns (eg. buildings, equipment, patents, copyrights, etc.) and you have an interest in the future income of the corporation - all relative to your ownership size (eg. if you own 1% of the shares you own 1% of the firm). If you owned a small business (eg. a small ice cream shop) in your neighborhood free and clear, you would own 100% of that shop - the same is true for a corporation except you will own a small percentage of it instead of owning it outright.
As the owner of the firm (as a shareholder), you are usually able to vote for certain things regarding firm decisions. The owners of the firm cannot run the firm by themselves (unlike the owner of a small business) so they appoint a board of directors who then hires managers (eg. CEO, CFO, COO, etc.) to run the day-to-day business of the corporation.
Let's Get a Bit More Complex and Consider Debt
As we said above, you literally own a piece of a corporation when you own a share of a firm, but that ownership is net of liabilities (debt) - that means that shareholders are second in line behind bondholders. If the corporation has no debt (if it's totally financed with equity), then there's no reason to even discuss debt at all. However, most corporations have significant amounts of debt (it's rational for corporations to use debt to finance various things), so we must take debt into account when calculating our ownership.
How can we take debt into account? We just do what you would do when calculating your net worth - we subtract liabilities from assets to come up with equity:
Once we figure out how much total equity is in a firm (the portion of assets financed through equity), we can divide that by the number of shares to determine the equity that corresponds to each share (this is somewhat of a simplification).
Additionally, as we stated above, we must keep in mind that debtholders hold senior claims to equity holders - that means that debts must be paid first before shareholders receive anything. Just like if you owned a house with a mortgage where the mortgage would have to be paid off first after you sold the house - the debt of corporation must be paid back before shareholders receive anything in a liquidation.
Assets > Financial Assets > Financial Derivatives
Another way to think of stocks is by understanding that they are financial assets. Real assets are things such as computers, desks, machines, and equipment while financial assets derive their value from these real assets. You can own real assets (eg. owning a computer or a piece of heavy equipment) but you can also have a claim on real assets through financial assets. A stock or share is a financial asset that gives the shareholder a claim on the real assets of a corporation and the income that those real assets produce.
Going a step further, we can have financial derivatives, which derive their value from financial assets. Financial derivatives such as options, futures, and forwards allow holders to have an interest in financial assets without actually holding financial assets.