Because bonus is realized for the contribution made over the past year while the person was employed. The companies performance to calculate bonus is the direct outcome of the performance of the employees combined during that period.
Good companies give bonus even when the employee is on a notice period. Great companies give bonus on a pro rata even when the employee isnβt currently employed.