How did night fighter aircraft manage to shoot down their foes in World War II?
The night fighting in WWII was mainly between the RAF and Luftwaffe, with the Luftwaffe fielding most of the night fighters due to necessity (the others too had some fine night fighters, though none had their need as much as the Germans).
The first stage in (trying to) shoot down enemy aircraft is to find them. This was mainly done by the ground based radars. The second one is fixing them- this is where the aircraft based radars came into being.
Initially, the fixing of aircraft location was done using ground based search lights, which were sometimes controlled by radar after which the fighters attacked the illuminated target- but this was of little use as was the aircraft based searchlights. It was only in the middle of the war did the development of night fighters gained pace.

A Messerschmidt  Bf 110 G-4 night fighter with FuG 202/220 Lichtenstein radar; By Max Smith - Own workMoved from en:Image:ME-110G-2_at_RAF_Hendon.jpg, Public Domain, Link
The night fighters were usually twin engined aircraft fitted with radars, though there some single engined ones too. The fighters were still vectored into the bomber locations using the ground radar controller. An RAF report on PoW interrogation notes:

...The crews fly by D.R., and the loose formation is simultaneously tracked on a map at Gruppe headquarters. If, in the light of the movements of the bomber force a change of course is necessary, a new bearing will be given to all aircraft simultaneously through the Gruppe commentary.
All crews are given strict orders to navigate by D.R., and to
accept the Gruppe orders if these differ from their own calculations ...

Once the fighters were near the bomber stream (as the RAF usually bombed in strength to overwhelm the defences), they were given a new bearing to intercept the bombers.

... the string of night fighters should be brought up to the bomber stream on a parallel or nearly parallel track. At the correct moment, and in accordance with D.R. tracking at headquarters, the night fighters will be given a new bearing which turns the whole line on to the bomber stream in a broadside.

The enemy aircraft (bombers) were identified by their silhouette (against moon or the burning cities below) or by their exhaust flames.

Recognition of the target aircraft is usually by the silhouette in light conditions or moonlight, and by the four exhaust flames in darkness.

The actual firing of the guns depended on the pilot and different ones opted for different methods- some simply did as in dogfights during day- get into the rear and shoot up, though the rear gunners made this difficult. Others moved towards the aircraft from the sides and a little low, after which they pulled up near the aircraft and aimed for the wing fuel tanks.

The range at which the night fighter opens fire with its forward
armament is determined by the pilot himself; whilst some will close in
as near as 50/60 metres, the more cautious will open up at a range of
200/250 metres. P/W considered, however, that the normal range might be
taken as l00/150 metres.

One of the effective methods used by Germans was the upward firing cannon called the Schräge Musik, which was quite effective with its 20 and 30 mm cannon.

By Source, Fair use, Link
Basically, the pilots flew under the bomber and fired the Schräge Musik. This was quite effective as the bomber crews had little warning of the threat below and the bullets usually tore through the fuel tanks near wing roots.

[These P/W] ... they stated that once this armament (Schräge
Musik) could be brought to bear it was extremely effective; one officer had claimed a kill with two rounds from the 20 mm. cannon.

The night attacks were quite short affairs as it was quite difficult to keep the bomber in crosshairs for any amount of time (and there were enemy night fighters to contend with). Shooting down enemy aircraft took more luck than skill in WWII. According to this site, each enemy aircraft shot down required more than 10,000 rounds fired (the values are more or less equal for both sides), with night attacks probably requiring more ammunition. Also, this infographic has some good details on this subject.