First of all, not all brokers allow trading during pre-market and post-market. Some brokers only allow trading during the regular hours (9:30am - 4pm ET).
Second of all, while you can place orders using limit orders and market orders during regular trading hours, you can only use limit orders during pre-market and post-market. This is because the liquidity is much lower during pre-market and post-market, and using market orders could result in some trades filling at horrible prices. So brokers don't allow using market orders outside of regular trading hours.
Third, some brokers require you to specify that you want your order to be executed during pre-market or post-market. For example, my broker allows me to specify either "Day" or "Ext" for my orders. "Day" means I want my order to execute only during regular trading hours, and "Ext" means I want my order to execute at any time - pre-market, regular trading hours, or post-market.
Finally, if your broker allows pre/post market trading, and you place a limit order while specifying "Ext", then your trade can happen in real-time during pre-market or post-market. Per your example, if a stock is trading at $5 at 8am, and you put in a limit order (while specifying "Ext") to buy it at $5 at 8am, then your order will execute at that time and you will buy that stock at 8am.