There are two types of stem, hopefully your replacement fork is compatible with the frame
This is also a fairly big job and if not done correctly can cause an accident. There's no shame in getting a bike shop to do this kind of work if you have any concerns.
Quill stem

These have a 6mm hex bolt that is accessed downward through a hole in the top of the stem. Loosen it ~5 turns and then give the allen wrench a light tap with a hammer, which will unseat the wedge (D in image) At this point the whole stem with handlebar attached should slide up and out.
Then undo the headset locknut and the headset nuts (unlabelled but just below C in image) There should be a bearing cage, but some bikes have hundreds of loose balls both above and below the head tube. Then the fork should slide out the bottom.
Threadless
These have a clear two-part design, where the stem is not shaped like a 7.

- Start by removing the top cap, probably uses a 5mm hex driver.
- Undo one or two pinchbolts that clamp the stem to the steerer tube and lift the stem and bars up and off the bike. Let them dangle by the wires
- Look for spacers - sometimes there are some above and below the stem. Save them.
- The fork may be loose to drop straight out the bottom. Look for greasy bearings, very likely in a cage. There may be other clips and seals depending on the design.
Reinstallation is essentially the reverse. You should clean and grease any bearings and races while its open. Avoid overtorquing bolts especially in threadless - they can strip the threads.
More info at