It is because of spreads and the quotes that you get through your broker. When buying, your broker gives you a quote that is slightly higher than the actual price and when you are selling your broker gives you a quote that is lower than the actual price