Elephants are most dangerous in two situations.
The first one: the male elephant in the musth.
Male elephant with tar-like liquid (temporin) on the sides of the head. That liquid comes out of his temporal glands. Musth usually happens during winter, and males can have 60x normal testosterone in their blood (sometimes even 140x more testosterone,) making them very aggressive towards anything nearby. To make things worse for elephants, their temporal glands become larger and it hurts them a lot. Elephants will try anything to get rid of pain, including attacking everything near them.
Second one: a mother with a baby elephant.
A mother will do anything to protect her baby. The mother thinks that anyone who isn’t part of her herd is a threat to her baby.