Cast a Spell does not inherently trigger Attacks of Opportunity.
Cast a Spell, on its own, is not a Manipulate action (it does not have the manipulate trait), it is not inherently a ranged attack, it is not a move action (it does not have the move trait), therefore it does not provoke attacks of opportunity on its own.
But Components can change that
Components add traits to the Cast a Spell activity, as follows:
- Material (manipulate)
- Somatic (manipulate)
- Verbal (concentrate)
- Focus (manipulate)
Therefor, if a spell requires one or more of Material, Somatic, or Focus components, the Cast a Spell activity gains the manipulate trait. And gaining the manipulate trait makes it trigger Attack of Opportunity. Note that this means spells which only require no components or Verbal components only do not satisfy the trigger.
All information comes from the section on Casting Spells, CRB 302, which includes a sub-section giving more information on the requirements of spell components.
Also note that being hit during the Cast a Spell activity does not on its own cause you to lose the spell or even make a save for the same. Attack of Opportunity does, however, disrupt the action (thus forcing you to lose the spell) if it critically hits. Other similar mechanics may or may not have similar clauses - Ranger's Disrupt Prey does disrupt the action on a critical hit like Attack of Opportunity, but Lesser Death's Lurking Death reaction disrupts the action if it hits.