It has been confirmed by The Pokémon Company that a glitch is currently affecting Friendly Competitions for Pokémon Sun & Moon. Players who scan QR codes for competitions which have not yet begun are sometimes being locked out of competing in them or losing their spot in the tournament.
Right now it is recommended to not scan QR codes unless a Friendly Competition has officially started.
We’ll post more as it comes, Pokémon is looking into the issue!