There are three ways in which a ticket can end up in the Spam folder -

1. Manually marked as Spam by an Agent.

2. Ticket marked as Spam by an Automation rule such as the Ticket creation or the Ticket Update rule.

3. Any ticket raised from a deleted user in Freshdesk would go to Spam automatically.