Unexpected trackpad or keyboard behavior is too often an indication that the battery has failed and is swelling. If so, you should get this evaluated by Apple as soon as possible. An expanding battery can exert enough pressure to cause irreparably damage and, because the rate of expansion can be fast, any delays increase the change of totaling the computer within days.
You can see if the lid closes properly or if the computer rocks on a known-flat surface. The bottom plate is the thinest part and will begin to bulge before other parts. The lid not closing is worse because that indicates damage, likely permanent, to the main deck that holds the keyboard and trackpad. If it:
- does not sit level
- the bottom plate contacts the flat surface
- or the lid won't fully close,
you have a serious battery issue. I mention that first because you cannot wait if that is the issue.
If the computer passes the "rock" test and the battery condition shows "normal," you can see if an SMC reset corrects the problem. These are the instructions, but make certain you use the right ones for your MBP sub-model:
How to reset the SMC of your Mac - Apple Support