Though much of Anubis' life before the events of the film are unknown, however, what is known is that he was lord of the dead well before the death of Osiris and had known Hathor from when she was mistress of the west.
Gods of Egypt (2016)
Throughout most of the film, Anubis would continue to perform his duties as lord of the dead was called upon a couple of times. The first time was by Horus, who called Anubis to bring Zaya's soul to begin her journey through the Nine Gates. He was later called by Hathor in hopes to make amends with Bek and for him to give Zaya the Bracelet of 42 Stars as her payment into the Afterlife. While this occurred, however, Anubis witnessed the gates of both the Afterlife and Underworld break, as a result of Set's confrontation of Ra. This meant Apophis could spread chaos as he pleased throughout all of creation.
Anubis held off the demon for a while, but his power wasn't infinite, meaning Horus and Bek had to hurry in order to restore balance before Apophis ate all of the world and afterlife.