Attacking, setting up and switching can all be useful. Start with what you want this turn: some damage, a Pokémon kept available, or a chance to attack next turn.
A switch may save your active Pokémon, but the replacement may have to take the opponent’s attack. If it has little HP, resistance alone is not enough: consider the hit, entry damage and what it can do afterwards.
An attack connecting is not the same as solving the problem. Damage, action order and the opponent’s response still matter.
Try explaining the purpose of your preferred action, then consider one other reasonable response from the opponent. What would you lose if your prediction is wrong, and what could you do next? The exercise asks for reasoning you can revisit, not proof of a unique best move.