Whenever I turn on the hot water, it takes 3-4 min to get hot water at the vanity. It takes 1-2 min. for the shower. I have a gas heater.
Can it be fixed or does it need to be replaced?
If you eventually get hot water, it is more likely due to the flow rate of the sink vs. the flow rate of the shower. This determines how fast the cooled water sitting in the pipes is pushed out before the hot water from the heater reaches the faucet.
In half inch pipe at a typical faucet flow rate of 1.5gpm, it will take 1 minute to clear roughly 18' of pipe. If you have a 3gpm shower head and the same length of pipe it would take half as long. This also assumes that both the shower and sink are being fed by the same size pipe and how the plumbing is routed. If you have a longer pipe run to the sink, it will take longer for hot water from the heater to reach it even at the same flow rate. 3/4" pipe will also take longer at the same flow rate to clear out the same length of pipe (about 12' per minute at 1.5gpm).
As @household Installs pointed out, different types of pipes and different levels of pipe insulation will effect the heat loss of water in the pipes when it isn't flowing. But you will always have heat loss that will eventually reach ambient temperature, and the amount of time it takes water to move from the heater to the faucet is a constant based on flow rate and capacity.
One solution for the sink would be installing a small on-demand hot water heater underneath and cut down on the amount of water you have to flush from the pipes between the heater and the faucet (and thus time spent doing so).
The fact that you get hot water means the hot water heater is doing it's job. The problem could be that your supply lines are getting cold and taking the heat from the water. If your supply lines are copper they take a little longer to heat up because the whole line needs to get to temperature. Cpvc pipe doesn't take as long. I'm guessing that you have copper to the sink but cpvc to the shower, maybe. If you insulate the pipes they will not get as cold. Insulate as much as you can get to.