In order to play in time when playing a musical instrument the musician needs to know several factors.
1. how long each note is to be sounded for .
2. how to play all the required notes in the piece on their instrument eg which key to press on the piano, what fingering to use on a wind or brass instrument, where you fingers should be on a string instrument.
3. if reading sheet music ( as opposed to playing by ear )
~ how to read the notes from sheet music
~ what the musical terminology means eg bars, barlines and time signatures.
If you don't know something from the above, then you need to find out. This can be done by asking your teacher, referring back to the relevant sections in your tutor book or online through places like google or THIS and THIS
Once you have found out the information it is a good idea to play exercises and pieces around this information just found.
A musician also needs to Count Steadily. Sometimes people understand how long the notes are they a playing but their counting is uneven. It is common to rush the counting on long notes and to play slurs too quickly. Sometimes people don't count at all and just guess!!!
Beginners learn to count the notes by note length
During their learning process they get to know counting per bar. And to do this they need to know what the time signature is, and what bars and barlines are.
eg 4 is 4 counts per bar.
You count through the piece with repetitions of 1 2 3 4 ie 1 2 3 4 l 1 2 3 4 l etc
Musicians need to practise to remember
To help keep in time when you are playing through a piece you can have an external beat being sounded. You can:
1. clap and count out loud, the piece or section
2. for non wind instruments , play and count out loud.
3. play and move a foot or big toe in a steady beat
4. play and use a metronome
Do so slowly and build up to the required speed.