Fork oil starts leaking when the seals get damaged. Seals get damaged because of accumulation of dirt and debris around the seals, which end up cutting it.
We don’t suggest you doing this at home. Rather go to a mech who can help change the seals.
If the stanchion is badly scratched, then the leak will continue, even after changing the seals.
Hope this helps!