Unfortunately that is life with a butterfly keyboard. If you are lucky, the issue is only caused by dirt or crumbs beneath the key caps. If so, then cleaning the keyboard by following the directions in this Apple article should help, just make sure to keep the can of compressed air completely upright or you may damage the laptop with cold wet propellant:
How to clean the keyboard of your MacBook or MacBook Pro - Apple Support
If cleaning the keyboard does not help, then you most likely have a hardware issue with the butterfly keyboard caused by both a design & manufacturing defect. This defect can cause a single keypress to repeat or not register at all. In that case, the Top Case Assembly will need to be replaced which is very expensive. If the Battery condition is showing "Service Recommended" or fails the Apple Diagnostics, then you can have Apple replace the Battery which will also give you a new Top Case Assembly (battery is glued to the underside of it), but at a much lower cost....just do not mention the key issues as some techs may insist on a more expensive repair to address the key issue.
Apple did have a free Keyboard repair program for the 2016-2019 laptops, but it is only valid for up to four years after purchase from Apple.....meaning your laptop probably will not qualify.
Keyboard Service Program for MacBook, MacBook Air, and MacBook Pro - Apple Support
FYI, here is an Apple article with the list of the current publicly acknowledged free repair programs for various Apple products:
Apple Service Programs - Apple Support