But how is a system able to recognize this particular payment was done?
Generate unique address for each payment and monitor payment to it. May be you can have a timer running, within which time frame the payment needs to complete. Otherwise you'd stop monitoring that address.
What if someone else just bought the same product and sent amount to this wallet?
Address is unique for each payment. So, this confusion will never occur.
So would it be necessary to create a new wallet for every payment?
A wallet is a collection of addresses, which can be accessed from the same seed/phrase. You generate new address for each payment. Not wallet.
Is this how popular systems work?
Not sure what do you mean by
popular. But, this is standard practice.
https://btcpayserver.org is an open source implementation of such a payment gateway.
Anyone got a better understanding of this?
Hope you understood the basics.