Given a board of $3 \times 3$ you want to write the numbers $1, 2, 3, 4, 5, 6, 7, 8$ and a number in their boxes positive integer $M$, not necessarily different from the above. The goal is that the sum of the three numbers in each row be the same
$a)$ Find all the values of $M$ for which this is possible.
$b)$ For which of the values of $M$ found in $a)$ is it possible to arrange the numbers so that no only the three rows add the same but also the three columns add the same?
### Part (a)

1. **Determine the row sum:**
   - The sum of the numbers from 1 to 8 is:
     \[
     1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 = 36
     \]
   - Let the sum of each row be \( S \). Since there are 3 rows, the total sum of the numbers in the rows is \( 3S \).
   - Including the number \( M \), the total sum of the numbers on the board is \( 36 + M \).
   - Therefore, we have:
     \[
     3S = 36 + M \implies S = 12 + \frac{M}{3}
     \]

2. **Determine possible values of \( M \):**
   - The row that contains \( M \) must have a sum of at least \( M + 1 + 2 = M + 3 \).
   - Therefore, we have:
     \[
     12 + \frac{M}{3} \ge M + 3 \implies 12 + \frac{M}{3} - M \ge 3 \implies 12 - \frac{2M}{3} \ge 3 \implies 12 - 3 \ge \frac{2M}{3} \implies 9 \ge \frac{2M}{3} \implies 27 \ge 2M \implies M \le 13.5
     \]
   - Since \( M \) must be a multiple of 3, the possible values of \( M \) are \( 3, 6, 9, 12 \).

3. **Verify each value of \( M \):**
   - For \( M = 3 \):
     \[
     S = 12 + \frac{3}{3} = 13
     \]
     Possible rows: \( (1, 5, 7), (3, 4, 6), (2, 3, 8) \).

   - For \( M = 6 \):
     \[
     S = 12 + \frac{6}{3} = 14
     \]
     Possible rows: \( (1, 6, 7), (2, 4, 8), (3, 5, 6) \).

   - For \( M = 9 \):
     \[
     S = 12 + \frac{9}{3} = 15
     \]
     Possible rows: \( (1, 5, 9), (2, 6, 7), (3, 4, 8) \).

   - For \( M = 12 \):
     \[
     S = 12 + \frac{12}{3} = 16
     \]
     Possible rows: \( (1, 3, 12), (2, 6, 8), (4, 5, 7) \).

### Part (b)

1. **Check if columns can also sum to the same value:**
   - For \( M = 6 \):
     \[
     \text{Possible rows: } (1, 6, 7), (8, 2, 4), (5, 6, 3)
     \]
     - Columns: \( (1, 8, 5), (6, 2, 6), (7, 4, 3) \)
     - Sum of each column: \( 14 \)

   - For \( M = 9 \):
     \[
     \text{Possible rows: } (1, 5, 9), (2, 6, 7), (3, 4, 8)
     \]
     - Columns: \( (1, 2, 3), (5, 6, 4), (9, 7, 8) \)
     - Sum of each column: \( 6, 15, 24 \)

2. **Prove that \( M = 3 \) and \( M = 12 \) do not work:**
   - For \( M = 12 \):
     - The only possibility for the row with \( 12 \) is \( (12, 1, 3) \), but since \( 1, 3 \) have been chosen for the row, they cannot come in that column.

   - For \( M = 3 \):
     - The only possibilities for the row with \( 8 \) are \( (8, 2, 4), (8, 1, 5) \), which forces the row with \( 7 \) to be \( (7, 3, 4) \), but since \( 3, 4 \) have been used in the row, they cannot appear again in the column.

The final answer is \( \boxed{ M = 6, 9 } \)