When you buy your own stock, you're increasing the amount of money an opponent needs to buy you out. Once all of your shares are purchased, their price effectively doubles (moreso, if you consider that the price goes up throughout the game and each time shares are bought). Buying your own stock for X forces an opponent to eventually earn at least twice that amount. If I buy one block of shares for $1000, then an opponent must pay at least $2000 for them, but much likely a lot more because by the time your stock is all bought (which is the only time your self-bought stock can be acquired), the price will be much higher than $1000. In a multiplayer game, a buyout actually pays that inflated price to the other stockholders! There have been exciting endings to games where one buyout triggers several others because of the sudden influx of cash going to the other players!
The only downside to buying yourself, is that it sets your own liquidity back a bit, and if you're relying heavily on the market to supply your colony with raw materials (or to rush-buy a building or improvement using public commodities), you'll sit there waiting to recover that cash, not expanding.
However, the earlier you buy stock, the cheaper it is and the bigger the difference in the eventual buyout price. Staying out of debt, being the first to build a structure type, and generally earning money all contribute to your price going up. If you have debt and you have $, unless you're saving that money for a specific purpose, pay off your debt (or keep it low with installments).
Debt occurs when you're forced to buy essential commodities from the market (power/water/food/O2/fuel/anything you set to Auto-Supply), and when you win an Auction. Most players don't realize that auctions can be won by anyone since you buy them on credit. When someone wins an auction, there is an immediate stock price drop as the debt is transferred. If you're quick you can get a cheap stock buy before the colony pays it off.
Also realize that if one or more colonies are buying essentials off the market due to personal shortages, that price will go up. I've seen games where I made a fortune off of switching to a Power-based economy because no one else was providing their own, and the price creeped up slowly. You can even see this over small timelines during the night as the solar panels turn off and colonies will resort to buying power off the market. Wind turbines generate less Power/sec than Solar panels but they are not subject to the "nighttime shortage", and you can make a few $ here and there by the slight price increase caused by nighttime power purchases. If everyone relies solely on solar power, that nighttime shortage increases as the game goes on, as power requirements increase across all colonies. If people are going to be throwing money at their problems, you want to make sure they're effectively throwing it at you.
In general, early purchases are cheaper than late ones, and sometimes it is cheaper to buy manufacturables off the market than investing in their production process. DO NOT BE AFRAID TO SWITCH OUT YOUR PRODUCTION TO TAKE ADVANTAGE OF TRENDS.