I heard it wears off after a few rides but it is still not gripping firmly. Is there any solution for this? I also saw using rubbing alcohol. Is that sufficient?
Disc brake pads are very sensitive to contamination. You can clean the disc rotors with rubbing alcohol, but that's about it. Anything else will contaminate the pads.
You may not be able to restore the pads. The easiest and surest thing would be to replace the pads.
If you want to try to restore the pads, get some "drywall sanding screen", remove the old pads, use the screen to remove the contaminated layer from the pads, and reinstall them.
Make sure to clean the rotors with rubbing alcohol before reinstalling the cleaned pads/installing new pads so no contaminant gets onto the restored/new pads.
Soak the pads in gasoline then light them on fire.
Don't laugh, I've done it and it worked.
Be prepared both to 1. safely extinguish the fire (can't use water!) and 2. throw out the pads if you ruin them.
You need only a tiny bit of gasoline both to 1. burn off the contaminants, or 2. start a major fire. The fire will go out when the gasoline is consumed.
Clean the rotors separately since the contaminated pads probably made them slick too. Use alcohol or other suitable solvent, not gasoline.
From my experience, having contaminated my pads a few times with hydraulic mineral oil due to sloppy brake bleeding or installation, what does the trick is simply thoroughly repeating the bedding-in process. Bedding-in is the procedure of getting brand new brakes to work properly (which they do not do out of the factory, on brand new bikes) by repeatedly braking hard to a stop from a reasonably high speed. This deposits some pad material on the rotor, providing much more friction than if the pad were in contact with bare steel of a new rotor, and also removes any contaminants from the surface of the new pad, which is why you generally have to bed in new pads a little, even when used with old rotors.
When the pad is seriously contaminated, you have to do this process quite rigorously. I get about this by climbing a sizeable hill with a road to descend down (this is more practical than doing it off road, even if you are on an MTB). The descent should ideally be steep enough to easily get you to sufficient speed (say 30 to 40 km/h, or less if safety is an issue and you don't mind doing more repetitions) and long enough that you can accelerate and decelerate several times, because you don't want to repeat the climb a zillion times. Last time I remember doing this it took me about 20 braking stints, or three descents, but then the brakes were fine (incidentally, it took me MUCH more to bed in brand new, clean, uncontaminated metallic pads after I replaced organic ones, so pad material can definitely influence how much bedding-in you might have to do). Of course, it helps if you clean the pads with isopropyl alcohol and sanding paper beforehand, as mentioned in the other answers.