Like @Tuomo and @Hayden have said, practicing with a metronome is very helpful, and like them, I highly recommend it.
There is another thing you will also benefit from doing, and it’s often neglected by players who are trying to improve their understanding and their skills around time, tempo, and rhythm: Ear Training.
When most musicians hear the phrase “ear training” they think of being able to hear the relationships among pitches, being able to execute solfège well, being able to play ideas that you hear in your head or from other musicians. But just as you must train your ear for facility with pitch, you must also train your ear for facility with time and rhythm and tempo.
When you listen to a pianist (or any other player, but in this forum we’re about piano), do you have a clear notion of where their playing stands with respect to the beat of the music? How would you describe the difference in timing approach between Oscar Peterson, Phineas Newborn, Errol Garner, and Joanne Brackeen? If you know those players but you don’t have a clear concept of how they differ in their approaches to time, I recommend doing some homework around this. It seems inscrutable at first, but eventually you will start to hear very clearly when someone’s melodies tend to be on the front, in the middle, or on the back side of the beat. You’ll hear differences in how they subdivide the swing. You’ll hear a lot of subtle things that grow less and less subtle as you grow more at ease with listening for them.
If you cannot hear those things in other players, or if you can hear them subconsciously but you don’t quite consciously know what you’re hearing, you will not be so easily able to identify what you’re doing in your own playing. This is the biggest reason why it matters.
Where do you WANT to be with respect to the beat? Do you want to be in the Joanne Brackeen place, or the Errol Garner place, or somewhere in between? There are a lot of choices! And once you decide how you WANT to sound, how does it compare to where you actually ARE in your playing?
Here is a sequence of steps I recommend as an extension of practicing with a metronome:
Pick a medium-tempo song you know well. This is not the time to prove you can play Cherokee in Gb at 320 bpm. If you don’t have a song you know well, it could be a blues, or a fairly straightforward standard – a couple of my favorites for this kind of work are “Lady Bird” and “There Will Never Be Another You.” There’s no shame in working on just one song over and over until you can use it as a comfortable practice vehicle.
By practicing with the metronome at a medium-slow tempo, get yourself to the point where you can play the melody of the song and play a simple comp with your left hand while you improvise over the chord changes with your right. Or for now if you like, you could concentrate just on the written melody – this will depend on how comfortable you are in your improvising. The point is to do something simple enough for you to feel comfortable and relaxed playing along with the metronome with both hands.
Record yourself playing the tune, either with the metronome or without (either way has its merits – in the long run you’ll want to do both). Listen back. Is the timing of your melody consistent and musical? Is the time of your melody positioned where you want it to be relative to the beat established by the metronome and/or your left-hand comping?
Lather, rinse, repeat. The point is to be able to consciously hear, and then consciously control, the approach you’re taking to the time. Eventually you can use exercises like this to learn things like consciously playing the melody behind the beat without dragging the tempo, for example.
In addition to the players I mentioned above, compare and contrast the different approaches to time taken by Diana Krall and Benny Green (both students of Oscar Peterson). Others whose style you can often identify just from their approach to time include Hank Jones, Jessica Williams, Wynton Kelly, Chick Corea, Mulgrew Miller, and on and on. Every accomplished player will have a consistent “pocket” where their time normally resides, and then by departing intentionally from that place they can create yet another kind of contrast in their playing. Even before you can easily do that yourself, it pays to listen with your “time ears” to the playing of others. Develop those ears!