Of course your queen can take the opponent’s queen. If the opponent’s queen is protected or not doesn’t matter. If his queen is protected then you will lose your queen as well as he will recapture if you capture his queen. In this case it was just an exchange of queens.
White moves – Queen takes Queen
In the position below White is exchanging queens 1. QxQ because this way he can destroy the right to castle for Black. However, as the most dangerous pieces – the queens – are off the board after this, Black is only slightly worse as he enters a middlegame without queens in which a king needs not to castle anymore as he can find a safe spot on c7, for example. (idea: c6 then Kc7)
Black moves and loses
Black must capture the queen. He has no time to retreat as then knight takes bishop and Black is a piece down and loses. But after Queen takes Queen White will not recapture the Queen immediately but takes the bishop with check first, and after that he recaptures the queen RxQ and is then a piece up and winning.