Question:
Why the shape of spike in spectrum analyzer is different with ideal spike?
Ideally we have learnt that the spike is a vertical line in frequency domain but in the real world it's not exactly so even if we give it a perfect e.g. sine wave. What is the reason?

the shape of the "spike " dsplayed is controlled by the bandwidth of the signal. a cw carrier is a smalll spike, an fm broadcast station is a broad spike. and these days a tv station looks like a "haystack" due to all the carriers it contains.
also, the badnwidth setting on the analyzer eill affect it, as well as the sweep rate, and the displayed bandwidth.

I suppose you are referring to an analog SA, correct?
In this case, there is indeed no "spike" - even not for a clean sinusoidal.
Instead , the screen shows the shape of the last IF bandpass filter.
By the way - this is also the reason for an upper search frequency limit because this filter needs a certain time to respond to the search signal.

In theory, a sine wave produces a delta function (a spike) in the frequency domain if the sample record is infinitely long.

In practice, a spectrum analyzer has a time limited record length. The resolution of the frequency spike is inversely proportional to the record duration. Hence you will experience spreading of the frequency spike.