How can I ensure that laptop batteries I buy are genuine?
Some sellers offer batteries for MacBooks cheaper than Apple. If it is a well-known manufacturer or seller, I would have less to think about. However, I would order from a trusted shop.
The only way to be sure of getting a genuine Apple replacement battery is to take your MBP to an Apple Store or other Apple-certified technician. The 13" 2012 MBP was sold by Apple up to 2016, so it is therefore still a supported model.
If someone is selling something claiming to be a genuine Apple battery, then it is either:
Produced at the original factory Apple used as a 'run-on' (extra copies made beyond Apple's order); or batteries that didn't pass Apple's Quality Control.
A counterfeit product made at another factory that has been set up to produce similar products, complete with Apple-branding stickers. The quality standards will be unknown.
As a result, the quality will be a bit of lottery. There's no way to tell whether it will work well, or whether it lose capacity quickly, or expand, or catch fire ... ;-)
That having been said, I've bought several batteries from Chinese factory outlets on eBay for old Unibody MBPs, and they've worked well for a number of years.