Why is there more gravity in the Andromeda galaxy compared to the milky way?

There isn't "more gravity" in the Andromeda galaxy, because that's essentially a meaningless phrase.

It used to be believed that the Andromeda galaxy was larger and more massive than the Milky Way. It's still thought to be larger (in terms of the number of stars), but the Milky Way may actually be more massive. It's hard for scientists to tell how exactly how big the Milky Way is because we're inside it and "can't see the forest for the trees".