A boy accused of attempting to hijack a plane believed he’d been exposed to “distressing” incidents and planned to flee Australia, a court has been told.