I expect these items were "sniper" bid. As mentioned, check the bid history - you should see the winning bid (higher than yours) was made within seconds of the auction end time.
A sniper waits until the last possible second or two and makes their bid. They will usually be ready to bid much higher than the current price - in anticipation of other snipers or that there may be an automatic bid in place that is higher than the current bid price showing.
The sniper may be waiting live or using a software package that make these sniper bids automatically. eBay is perfectly ok with this, so it is not against any rules.
Depending on the speed of your Internet service, you may see the bid price change moments before the auction ends. But if yours is slow, you may not know you lost until the auction ends and you see the grey bar.
Only recourse is to try sniping yourself. Or put in high automatic bids of your own - hopefully it will be higher than the sniper will try.
http://pages.ebay.ca/help/buy/automatic-bidding.html
In all cases, best bidding strategy is to decide what you are willing to pay. Do research on what that item, or something similar, has sold for before. Then bid to that amount. Late bidding can work well, but not always because someone else may bid to the same max amount as you - BEFORE you do.
Do a bit of research. Strategies can vary with the item, category and market. Make informed choices and don't get caught up. Be sure you are satisfied with your max bid amount - will you be annoyed if someone else gets the item for 5 cents more? If you win, will you wish you hadn't bid so much?
Have fun!