For publicly traded shares, the exchange is what prevents this from happening. At any given time for any reasonably liquid stock there will be a list of buyers with bids to buy a number of shares at a given price and a list of sellers with offers to sell their stocks at a given price.
If you stop the clock here, you will observe that no shares are trading hands and there are a large number of shares sitting out on offer to either buy or sell at a range of prices. It will always be the case at any given time that the highest bid price to buy any of these shares will be lower than the lowest offer price - otherwise a transaction would be taking place and the share price would move.
So the last traded share was done at $20/share and the market then might look something like this
Offers to sell
- ... etc ^^^
- 5000 shares @ $22.00
- 4400 shares @ $21.40
- 3700 shares @ $21.15
- 4200 shares @ $20.75
- 1200 shares @ $20.17
STOCK TICKER PRICE $20.00
Bids to buy
- 1320 shares @ $19.70
- 3100 shares @ $19.00
- 5700 shares @ $18.77
- 6000 shares @ $18.12
- ... etc vvv
So when your sly friend goes to the exchange to offer to sell his share for $100 he simply goes into the offers list way up the chain behind everyone else who is willing to sell their shares for a lower price.
When a buyer goes to the exchange to buy a share they can't choose which they will buy - they can choose to either post a bid at a price of their selection and wait for a seller to come along willing to sell at that price, OR, they buy at the market price.
In this case, let's take our spread of bids and offers above as example, and let's say our buyer enters the market willing to buy 7000 shares at market prices. The exchange will negotiate the transaction from the available share pool as:
- 1200 shares @ $20.17
- 4200 shares @ $20.75
- And the remaining 1600 shares from the available 3700 @ $21.15
After this transaction the exchange will list the stock price as the last transaction price - this buyer, in buying these shares, will have moved the stock price up to $21.25.
If no other buyers or sellers act during this time the bid-ask spread will have increased from $0.47 to $1.45 and other buyers and sellers may adjust their positions in reaction to this.
This is the whole point of the market - a single individual with a single transaction cannot materially affect the price of a stock without engaging in such a significant purchase or sale of stock that they consume all of the outstanding bids and/or offers between the current share price and their "target" price. If you want to move a stock from $20 to $100 you have to buy a LOT of shares. Furthermore, you can't move a stock price UP by selling shares at market prices and you can't move it DOWN by buying shares at market prices.