  Two unresolved questions at galaxy centers, namely the formation of the
nuclear star cluster (NSC) and the origin of the gamma-ray excess in the Milky
Way (MW) and Andromeda (M31), are both related to the formation and evolution
of globular clusters (GCs). They migrate towards the galaxy center due to
dynamical friction, and get tidally disrupted to release the stellar mass
content including millisecond pulsars (MSPs), which contribute to the NSC and
gamma-ray excess. In this study, we propose a semi-analytical model of GC
formation and evolution that utilizes the Illustris cosmological simulation to
accurately capture the formation epochs of GCs and simulate their subsequent
evolution. Our analysis confirms that our GC properties at z=0 are consistent
with observations, and our model naturally explains the formation of a massive
NSC in a galaxy similar to the MW and M31. We also find a remarkable similarity
in our model prediction with the gamma-ray excess signal in the MW. However,
our predictions fall short by approximately an order of magnitude in M31,
indicating distinct origins for the two gamma-ray excesses. Meanwhile, we
utilize the catalog of Illustris halos to investigate the influence of galaxy
assembly history. We find that the earlier a galaxy is assembled, the heavier
and spatially more concentrated its GC system behaves at z=0. This results in a
larger NSC mass and brighter gamma-ray emission from deposited MSPs
