There are several times in the books (and movies) where it is either mentioned or depicted that magical people, in moments of stress, are capable of accidentally causing magic to happen. The biggest examples are probably in the first book when Harry makes the glass disappear from the boa's tank at the zoo (it is also mentioned that accidental things have happened before earlier in his childhood), and in the third book when he inflates Aunt Marge.
The thing I've noticed, though, is this only ever seems to happen when they're out in the Muggle world, surrounded by non-magic folk. It is fairly obvious Harry faces some extremely stressful situations while at Hogwarts (the books wouldn't be very exciting otherwise!), and yet throughout all of those situations, Harry (or the other characters for that matter) never once make anything accidental happen like what happened with Aunt Marge. Is there a particular reason for this?
Note: Canon answers would be greatly appreciated.