Could you please explain the algorithm used to create a magic square? I'm interested in understanding the process behind constructing one of these fascinating puzzles. How does the algorithm ensure that the sum of the numbers in each row, column, and diagonal remains the same? Is there a specific sequence or rule that must be followed in order to achieve this? I'm eager to learn more about this intriguing mathematical concept.