If this is a tablet you're talking about, then you're probably activating the tablet's smartcover sensor (which is typically located somewhere in the bezel and is triggered by a weak magnet that is embedded in the case's cover). So if your phone is in a case that also has a magnet, then the phone case's magnet might be triggering the tablet's smartcover sensor.