The dimension of a system is the minimum number of numbers required to completely communicate the state of the system.
Say you have a closed system filled with an ideal gas. The system is described by $PV=nRT$. $R$ is a costant, so is $n$ since the system is closed. If I tell you the value of $(P,V)$, you have all the information needed to recreate the system. Therefore the dimension of this system is two. (This is assuming we treat the value of R and n as already known and agreed upon. Suppose you're communicating this to your friend in another universe where the value of $R$ is different, or instead of a closed system you have an open one; then the dimension becomes three).
On the other hand the dimension of spacetime has got nothing to do with its state. There, using four numbers we are specifying a point in space and time. It's like telling you latitude, longitude, altitude and the time at which the above said closed container exists.
What we mean by dimension is physically different in both cases, yet mathematically it is quite the same, the minimum number of numbers to specify something. If you're still interested I'd suggest reading about vector spaces, bases and the dimension of a vector space.