You hit on a pretty broad subject there with a fairly sweeping generalization. Look into the concept of liquidity and market making for starters.
When you place an order, there has to be someone on the other side to take the trade. The trade will execute at the best available price if it's a market order, or your price if it's a limit order. You can sort of "guarantee" this price with the limit order, but not always. Also take the spread into account.
As for FB, it was an unusually hyped event so it played out differently than it normally does. For various reasons, shares were not always available for trading and (lack of) liquidity may have caused severe price volatility.
Anyway, to have a better guarantee of price, you want high liquidity (lots of orders/participants) so that you can be relatively certain there'll be someone on the other side to provide your price. Low liquidity assets should be avoided since your price is unlikely to be hit for lack of available counterparties, large spread, and the possibility that even your small order could push price around.
Much more could be said on the topic, but that's the gist of it.