They mean the exact opposite, in my mind.
Roaming is going places with no definite destination or goal.
Loitering is staying in one place with no purpose in mind. You are now waiting for anybody and don't intend to accomplish anything where you are. Just sitting or standing somewhere is usually only considered loitering in a place where authorities expect people to keep moving or have some reason to stay. Just standing in a subway walkway would probably be considered loitering.