Against and on are commonly used interchangeably. I'll talk you through each one to make sure you understand the difference, in general against is used to mean on the side of rather than from any direction.
She was resting her head against the side of the chair.
I accidentally knocked my head against the shelf.
On and against are both fine here.
She accidentally brushed against him as she walked by.
In this context, if you replace with "on" it doesn't make sense. Brushed against someone is the act of physically touching them as you walk past, if you replace with "on" it almost means to be on top of them in some way.
Profits are up this year against last year.
This sentence doesn't really make sense. Should be "Profits are up this year since last year" or even better "Profits are up compared to last year". The reason is that in this context against is usually used in a competing sense like: "England are playing football against Spain this weekend". Profits can't compete with each other.