There are some situations where these can be used interchangeably:
play a prank on someone
play a trick on someone
These are mostly the same in meaning.
However, "trick" has a much wider meaning than "prank". In fact, you can think of a "prank" as just one kind of "trick" - it's the kind where you're doing something to surprise or scare the person to be funny. As LeUyenHoc said, "tricking" someone can mean a wider range of things, including scamming someone out of their money, lying to someone, etc.
A "trick" is also another word for something done via slight of hand like with a deck of cards.
A "trick" can also be something quite positive, as in for example if you are explaining a difficult manoeuver such as parallel parking on a busy street............ "The trick here is, that you have to learn to be quick when there is a little break in the traffic flow."