I gave my MacBook Pro (15" Touchbar one) to the service centre for
replacing the keyboard...
This is the key element to your answering your question.
When you need to have your keyboard replaced, they don't replace the keyboard; it's too time consuming and labor intensive (and somewhat dangerous due to the battery). They replace the entire top case assembly.
The top case is an assembly of the following (major) components/sub assemblies:
- Aluminum case housing
- Track pad
- Battery pack
The battery pack is glued in place and Apple advises service centers to not attempt removal; so they don't. They just replace the entire thing.
If you took your MacBook to an authorized service center, everything will be genuine Apple parts.
Regarding the lower run times...
You may have received something called NOS (New Old Stock) meaning the top case may be new, but it's been sitting on a shelf for a couple of years. The battery, though unused, is still degrading even though it's sitting on a shelf somewhere. Return it to your service center and make them aware of the issue.