It's interesting that you asked about how the atoms of the rock behave - if we can understand that, then we can understand how the rock became a magnet!
One important property of atoms is that they may contain something called a "magnetic dipole moment." That may look complicated, but all it means is that some atoms act like tiny little magnets. Unfortunately, scientists aren't quite sure why this is true - it's something that scientists have discovered by studying the properties of atoms.
The way that a rock becomes a magnet, then, is by having all of these little magnets point in the same direction within the whole rock. So you basically have a bunch of little magnets, all pointing in the same direction. This makes a great big magnet, like the rock you saw!
So if you wanted to make a rock magnetic, how could you do it? The answer if by placing it within a magnetic field, maybe by putting it next to another magnet. This makes all the little magnets in the atoms point the same way, and some atoms, like Iron atoms, like to keep all those little magnets pointing in the same direction for a long time after the other magnet is taken away.