Yes they are the same. However, Beforehand" and "ahead of time" can be used slightly differently too:
Beforehand: This is often used to describe something done earlier, typically in relation to an event or action. It’s a bit more neutral in tone.
Example: "I should have read the instructions beforehand."
Ahead of time: This phrase emphasizes the idea of doing something earlier than necessary, often with the intention of being prepared or proactive.
Example: "We need to plan ahead of time for the meeting."