Entanglement
Pieces can capture another active piece by landing on their initial position before it moves. This is called an entanglement.
If the active piece being captured is not attacking the attacker, then the active piece's move does not occur, including any potential captures.
In this example, the white queen may randomly guess from where the attack is coming from to prevent checkmate by attacking that piece. However, the other piece could be the attacker.
Try this out by attempting to capture black's bishop on h5. The black queen will prevent this by entangling with your queen instead.
A better play would have been to choose another piece to block the path of one of the pieces.
If the knight blocked the active black queen, then the white c2 pawn could then capture the queen, however the white queen is still vulnerable to the bishop. If instead the bishop takes the queen, the king could capture the bishop as the knight blocks the black queen from checking the king.
If a pawn blocked the active bishop then it could then take it or the king could then freely take the black queen.
Notice in the move list your attempt at moving was still listed although it did not occur.