In the simplest terms, you open at the worst of the 2 prices and close at the worst of the 2 prices.
So, if price did not move, the price was 1.00000/1.00020 (2 pip spread) and you opened a position and then closed it, you would be down 2 pips (20 points on a 5 digit broker).
Using the numbers above, if you buy, the position opens at the least advantageous price (1.00020) and closes at the least advantageous price (1.00000). If you sell, the position opens at the least advantageous price (1.00000) and closes at the least advantageous price (1.00020).
So, you only pay the spread once, but if you don't turn on that ask line, you may not realize exactly when and where that spread is hitting you.