why does my whatsapp sometimes show me as having been online when I didnt log on at any stage
No. It is not related to phone problem.

When your WhatsApp in foreground then it will shows as online to others.
When it is in background (After removing from recent tabs), it will shows last seen to others.

Sometimes if your WhatsApp in recent tabs then it will shows online to others.