Perez wanted to tempt Allegri to Spain in the aftermath of Zinedine Zidane's resignation, but eventually went with Julen Lopetegui as the Frenchman's successor.
Allegri recalled: "I knew this question was going to come out, but I just followed my instinct.
"This summer was not easy for me because I lost my mother a month ago. I had to make different choices. I spoke with Juventus and I'm fine here.
"I still thank Real Madrid president Florentino Pérez. I know he looked for me, but I had already spoken with Juve, who had an important project."