It tends to depend on what you are using the Pokemon for.
A dedicated Sweeper will usually be best served by maxing EVs in Speed and the attacking stat it is using, and throw the leftovers into HP. A Wall will usually max out HP, and the defense it already has a lot of, with the leftovers thrown in the attacking stat their movepool favors. Both of these team roles are all designed to do 1 thing, and do that thing really, really well.
A Bulky Sweeper, a Tank, and a Support, on the other hand, all function differently. They need their stats spread out more, because they are intending to use more of them. With finite EVs available, you usually have very tight optimizations to get what you want out of the Pokemon.
A Tank usually wants to equalize it's Defense and Special Defense while still raising both of them, but it also needs to get more Health. It takes a bit of math to figure out how high to raise these 3 stats to get the most effective health out of the Pokemon, regardless what is attacking it. I did this with a Giga Drain Sub Seeder Venusaur, and it has proven quite effective.
A Bulky Sweeper still needs to worry about it's attacking stat and speed, but it's bases in one or both of these things are a bit lower than dedicated Sweepers, but usually have an Ability or access to a move that makes up for the loss on outright offense. This usually means that it needs to be able to survive a few attacks in order to be worth the slot on the team. This means you need to worry about optimizing at least it's Health in addition to it's attacking stat and Speed. Sometimes it's even wise to put some amount of points into one of it's defenses to shore up a weakness. You usually want to further supplement them with a defensive or recovery item.
A Support usually lands somewhere between a Wall and a Tank. It needs to survive hits that may come it's way, especially if your particular Support is highly important to your team as a whole (like a "Weatherman"), or is needed to make a certain other Pokemon on your team "go" (like a setup Baton Passer). Like a Tank, this means you need to optimize all 3 defensive stats -- Health, Defense, and SpDef. But, depending on the Pokemon and it's supportive duties for it's team, you may also need to put some amount of Speed into it, to ensure it moves before the Pokemon it is supporting.
As a competitive novice myself, I'm sure I'm overlooking other team roles and important points, but I think I covered most of the bases.
As this relates to Aerodactyl specifically, I believe Aerodactyl sits squarely in the realm of Dedicated physical Sweeper. This would mean that you want to max it's Attack and Speed, and throw it's leftover points into Health. However, Mega Aerodactyl's stat hole on Defense is filled in, as well as it's ability Tough Claws amplifying moves that make contact. This gives it the option of running as a Bulky physical Sweeper instead.