First, note that a share represents a % of ownership of a company. In addition to the right to vote in the management of the company [by voting on the board of directors, who hires the CEO, who hires the VPs, etc...], this gives you the right to all future value of the company after paying off expenses and debts. You will receive this money in two forms: dividends approved by the board of directors, and the final liquidation value if the company closes shop. There are many ways to attempt to determine the value of a company, but the basic theory is that the company is worth a cashflow stream equal to all future dividends + the liquidation value. So, the market's "goal" is to attempt to determine what that future cash flow stream is, and what the risk related to it is.
Depending on who you talk to, a typical stock market has some degree of 'market efficiency'. Market efficiency is basically a comment about how quickly the market reacts to news. In a regulated marketplace with a high degree of information available, market efficiency should be quite high. This basically means that stock markets in developed countries have enough traders and enough news reporting that as soon as something public is known about a company, there are many, many people who take that information and attempt to predict the impact on future earnings of the company.
For example, if Starbucks announces earnings that were 10% less than estimated previously, the market will quickly respond with people buying Starbucks shares lowering their price on the assumption that the total value of the Starbucks company has decreased. Most of this trading analysis is done by institutional investors. It isn't simply office workers selling shares on their break in the coffee room, it's mostly people in the finance industry who specialize in various areas for their firms, and work to quickly react to news like this.
Is the market perfectly efficient? No. The psychology of trading [ie: people panicking, or reacting based on emotion instead of logic], as well as any inadequacy of information, means that not all news is perfectly acted upon immediately. However, my personal opinion is that for large markets, the market is roughly efficient enough that you can assume that you won't be able to read the newspaper and analyze stock news in a way better than the institutional investors. If a market is generally efficient, then it would be very difficult for a group of people to manipulate it, because someone else would quickly take advantage of that. For example, you suggest that some people might collectively 'short AMZN' [a company worth half a trillion dollars, so your nefarious group would need to have $5 Billion of capital just to trade 1% of the company]. If someone did that, the rest of the market would happily buy up AMZN at reduced prices, and the people who shorted it would be left holding the bag.
However, when you deal with smaller items, some more likely market manipulation can occur. For example, when trading penny stocks, there are people who attempt to manipulate the stock price and then make a profitable trade afterwards. This takes advantage of the low amount of information available for tiny companies, as well as the limited number of institutional investors who pay attention to them. Effectively it attempts to manipulate people who are not very sophisticated.
So, some manipulation can occur in markets with limited information, but for the most part prices are determined by the 'market consensus' on what the future profits of a company will be.
Additional example of what a share really is:
Imagine your neighbor has a treasure chest on his driveway:
He gathers the neighborhood together, and asks if anyone wants to buy a % of the value he will get from opening the treasure chest. Perhaps it's a glass treasure chest, and you can mostly see inside it. You see that it is mostly gold and silver, and you weigh the chest and can see that it's about 100 lbs all together. So in your head, you take the price of gold and silver, and estimate how much gold is in the chest, and how much silver is there. You estimate that the chest has roughly $1,000,000 of value inside. So, you offer to buy 10% of the chest, for $90k [you don't want to pay exactly 10% of the value of the company, because you aren't completely sure of the value; you are taking on some risk, so you want to be compensated for that risk].
Now assume all your neighbors value the chest themselves, and they come up with the same approximate value as you. So your neighbor hands out little certificates to 10 of you, and they each say "this person has a right to 10% of the value of the treasure chest". He then calls for a vote from all the new 'shareholders', and asks if you want to get the money back as soon as he sells the chest, or if you want him to buy a ship and try and find more chests. It seems you're all impatient, because you all vote to fully pay out the money as soon as he has it.
So your neighbor collects his $900k [$90k for each 10% share, * 10], and heads to the goldsmith to sell the chest. But before he gets there, a news report comes out that the price of gold has gone up. Because you own a share of something based on the price of gold, you know that your 10% treasure chest investment has increased in value. You now believe that your 10% is worth $105k. You put a flyer up around the neighborhood, saying you will sell your share for $105k. Because other flyers are going up to sell for about $103-$106k, it seems your valuation was mostly consistent with the market.
Eventually someone driving by sees your flyer, and offers you $104k for your shares. You agree, because you want the cash now and don't want to wait for the treasure chest to be sold. Now, when the treasure chest gets sold to the goldsmith, assume it sells for $1,060,000 [turns out you underestimated the value of the company]. The person who bought your 10% share will get $106k [he gained $2k]. Your neighbor who found the chest got $900k [because he sold the shares earlier, when the value of the chest was less clear], and you got $104k, which for you was a gain of $14k above what you paid for it.
This is basically what happens with shares. Buy owning a portion of the company, you have a right to get a dividend of future earnings. But, it could take a long time for you to get those earnings, and they might not be exactly what you expect. So some people do buy and sell shares to try and earn money, but the reason they are able to do that is because the shares are inherently worth something - they are worth a small % of the company and its earnings.