Was it certain parts of the enemy plane? Was it the enemy pilots? Was it just a crap shoot, trying to hit anything? In movies and old footage it's hard to tell exactly what their aim is or what they were trained to do in a fight.
They aimed to hit the enemy aircraft wherever they could. The goal was to cause enough damage to destroy the enemy aircraft. If a pilot could see the shell impacts on the target, they would try to 'walk' the fall of shot towards critical systems such as engines, fuel tanks and pilots.
Many aircraft guns would exhaust their ammunition in 10-20 seconds of continuous fire. Most would overheat and jam in prolonged continuous fire anyway. Short 3-5 round bursts until you hit the target, then continuous fire until your guns are empty, or the target is no longer in your sights.
On most sorties, you would not fire your guns. If you did get an enemy in your sights, you would do your best to fire every round you had in an effective way.
As a pilot of a fighter, you had three goals:
Locate the enemy. The sky is a big place. Use ground or ship radar, intel, w/t from other fighters, and the Mk 1 eyeball to spot the enemy.
Engage. Use the performance of your aircraft, your tactical awareness, and your superior airmanship to close to an attacking position
Destroy. Position your weapons to deliver ordnance on the enemy without being destroyed yourself.
Once engaged, you would try to maintain the engagement until the enemy was destroyed, you were destroyed, or you could no longer contribute to the destruction of the enemy.
Aircraft are astonishingly fragile. They are loaded with fuel, they are packed with vulnerable hydraulic, electrical and mechanical systems. Any hit from a bullet is likely to cause significant damage. Large-calibre hits, or multiple hits from a lighter weapon, are likely to be fatal. Expert pilots would develop individual tactics against specific aircraft, and those tactics would - if successful - become doctrine. Some enemy aircraft had engineering or design weaknesses that favoured specific attack strategies.
I would recommend the book "Flying Guns of WW2" by Anthony Williams for a proper historical review of airborne projectile weapons of that war.
To get into position to make effective attacks, the legendary "Dikta Boelke" from the famous WW1 ace is valid even into this day of stealth and data.
Maneuvering several tons of metal around without any avionics and flight computers was already challenging enough, scoring precise hits was even tougher, on a maneuvering target, nigh impossible. Guess why aircraft carried so much ammunition with them. Of course, there are preferable places to strike on an aircraft. Slower, lumbering targets, such as bombers, which generally wouldn't maneuver against an attack, often drew fire to their engines or wings. Desired targets are the pilot, control surfaces, the engine(s) and the wings. In general, due to technological limitations of this timeframe, you could shoot almost whereever you want and still deal effective damage.
Most nations used a mix of 20mm autocannons, rifle-caliber and heavy machineguns, the Americans being the only nation which mainly relied on its .50 caliber AN/M2 Browning. Most of this weapon's destructive power came from its API (armour piercing incendiary) bullets, which would frequently set fuel tanks on fire and its capability of being mounted in bigger numbers, the majority of American fighters were armed with 6 guns, while 20mm autocannons were mounted in numbers of 1-4, countering the increased effectiveness per shot of autocannons. In comparison, it needed more hits to down an aircraft, but the higher density of fire made them effective weapons nonetheless.
Also noteworthy, the Germans had all of their fighter aircraft armed with 20mm or even 30mm autocannons that could fire so-called "Minengeschoss" (lit. mine shell) rounds. A development from regular HE (high explosive) shells used in cannons of such caliber at the time, these thin-walled projectiles could carry comparable large amounts of explosive filler and exploded while penetrating its targets soft skin, essentially tearing chunks of metal out of an aircraft. It didn't really matter where those shells struck, especially the 30mm Minengeschoss fired from the Mk 103 and Mk 108 later in the war was a dreaded weapon that could cripple a fighter aircraft in a single hit.
The book German Aces Speak has Aces talking about their tactics, tips and procedures and gives you a great insight about how they led their squadrons and pioneered tactics like aiming to knock out oil pumps or tanks on certain aircraft to cripple them. They also talk about the need for efficiency, war materials were at a premium and the Germans couldn't waste fuel, ammo, planes, maintenance manpower or lives on inefficient attack tactics and how it determined their air defenses.