First of all, we should talk about storms. There are a few different types, but what matters here is that the type we see most often in our neck of the woods is an extratropical cyclone. They form between 30° and 60° North or South of the Equator, and generally look something like this:
Note the hurricane-like rotation.
Now, hurricanes are another type of storm, called a tropical cyclone. They form in the tropics, or from 30° N to 30° S. They have a unique shape, and also have a distinct eye. These are our hurricanes (Atlantic) and typhoons (Pacific). Tropical cyclones have a low pressure center with bands of thunderstorms radiating out from that. In contrast to extratropical cyclones, most of the rain and wind is concentrated at the center of the storm, and they are known as "warm-core" systems.
This beauty is Hurricane Katrina, just after landfall.
Now that we know what those two types of storms look and act like, we'll take a look at Hurricane Sandy. This particular storm started as a depression south of Jamaica, and due to favorable conditions, intensified to a Tropical Storm on October 22. It moved north across Jamaica, Cuba and the Bahamas over the next 4 days, intensifying to a Category 1 (or weakest class) hurricane on Oct 24.
As Sandy exited Cuba, it fell apart, and this is where it gets interesting. Conditions allowed the storm to maintain convection (drawing warm air up from the ocean) and kept it from dissolving completely. As it moved north, it formed an eye again and was upgraded to a hurricane once more. At the same time over the continental US, a large trough was moving into the Eastern US and creating a situation that looked like this:
Credit goes to Dr. Chris Martucci at epawablogs.com
Normally, a trough that deep would block the hurricane and force it northeast, out into the Atlantic. In the picture above, you can see that there's a high pressure system off the coast of Greenland, and a low pressure system to the south of that. These two systems blocked Sandy's "escape route", so to speak, and with nowhere to go but northwest, it was captured by the trough and slammed right into New Jersey and New York City. Here's a satellite photo to give some more idea of what this looked like:
In the top right, you can see the low pressure system swirling east of Canada, and Hurricane Sandy near Florida. That long band of clouds stretching from Texas through Canada is the trough that pulled Sandy in.
As Sandy moved north, it began to interact with this trough and lose some of its hurricane characteristics, becoming an extratropical storm. As it moved in near New Jersey, it lost some convection but intensified due to the interaction between it and the low pressure system to the west. At this point, Sandy's wind field was over 1800 km wide (or 1150 mi). At landfall on Oct 29 it was declared post-tropical (which means it had transitioned to an extratropical storm).
via NASA Earth Observatory
So to recap: Sandy started as a hurricane, should have been pushed out to sea by a trough in the Eastern US, was blocked by weather systems in the Atlantic, which pushed Sandy back towards the trough, and then finally was intensified by interactions with the trough to become one of the costliest US hurricanes in recorded history.