Why do people bid on online auctions sooner than a few seconds before it ends?
One advantage of auctions, to the seller, is that buyers can get caught up in bidding wars and spend more than they intended to.  Any auction platform that gets paid by what the auction takes in is going to want or hope for that.

I assume you're referring to eBay-style auctions.  eBay encourages bidding frenzies.  If you bid on an item and are outbid, they will notify you and encourage you to bid more.  As the auction draws to a close, they will notify bidders who aren't currently in the lead.  They're hoping at least some bidders will think bidding is fun, and will think of winning the auction as succeeding.  The thrill may be that of gambling or similar.

I don't see any advantage in waiting for the last few seconds.  I decide how much I'm willing to pay for something, and enter that amount whenever.  The only way someone will find out how much I bid is to outbid me, and then I don't want to win the auction.  Trying to time my bid for the end of the auction would sometimes be very inconvenient.  If there's going to be a bidding frenzy at the end, the price will either go over mine or not, and I think it very unlikely that when I bid makes much difference in that.  It should be clear that I don't think bidding by itself is fun, and that I don't want to win the auction by paying more for an item than I value it, which as you've seen isn't the universal approach.