Find all functions $f: \mathbb{N} \rightarrow \mathbb{Z}$ such that $|f(k)| \leq k$ for all positive integers $k$ and there is a prime number $p>2024$ which satisfies both of the following conditions:

$1)$ For all $a \in \mathbb{N}$ we have $af(a+p) = af(a)+pf(a),$
$2)$ For all $a \in \mathbb{N}$ we have $p|a^{\frac{p+1}{2}}-f(a).$

[i]Proposed by Nikola Velov[/i]
1. **Given Conditions and Initial Observations:**
   - We need to find all functions \( f: \mathbb{N} \rightarrow \mathbb{Z} \) such that \( |f(k)| \leq k \) for all positive integers \( k \).
   - There exists a prime number \( p > 2024 \) satisfying:
     1. \( af(a+p) = af(a) + pf(a) \) for all \( a \in \mathbb{N} \).
     2. \( p \mid a^{\frac{p+1}{2}} - f(a) \) for all \( a \in \mathbb{N} \).

2. **Analyzing the First Condition:**
   - For \( a = 1 \):
     \[
     1 \cdot f(1 + p) = 1 \cdot f(1) + p \cdot f(1) \implies f(1 + p) = (1 + p) f(1)
     \]
   - For \( a = p \):
     \[
     p \cdot f(p + p) = p \cdot f(p) + p \cdot f(p) \implies p \cdot f(2p) = 2p \cdot f(p) \implies f(2p) = 2 f(p)
     \]
   - By induction, we can generalize:
     \[
     f(kp) = k f(p)
     \]

3. **Analyzing the Second Condition:**
   - For \( a = p \):
     \[
     p \mid p^{\frac{p+1}{2}} - f(p) \implies p \mid p^{\frac{p+1}{2}} - f(p)
     \]
     Since \( p \mid p^{\frac{p+1}{2}} \), it follows that \( p \mid f(p) \). Therefore, \( f(p) = \epsilon p \) where \( \epsilon \in \{-1, 1\} \).

4. **Generalizing for \( kp \):**
   - By induction, if \( f(p) = \epsilon p \), then:
     \[
     f(kp) = k f(p) = k \epsilon p
     \]

5. **Considering \( x \not\equiv 0 \pmod{p} \):**
   - From the first condition:
     \[
     \frac{f(x+p)}{x+p} = \frac{f(x)}{x}
     \]
     This implies:
     \[
     f(kp + r) = (kp + r) \frac{f(r)}{r}
     \]
     where \( r \in \{1, 2, \ldots, p-1\} \).

6. **Implications for \( r \):**
   - Since \( r \mid f(r) \), we have \( f(r) = \epsilon(r) r \) where \( \epsilon(r) \in \{-1, 1\} \).
   - Therefore:
     \[
     f(x) = \epsilon(x) x
     \]

7. **Verifying the Second Condition:**
   - We need \( p \mid x \left( x^{\frac{p-1}{2}} - \epsilon(x) \right) \).
   - For \( r \neq 0 \):
     - If \( r^{\frac{p-1}{2}} \equiv 1 \pmod{p} \), then \( \epsilon(r) = 1 \).
     - If \( r^{\frac{p-1}{2}} \equiv -1 \pmod{p} \), then \( \epsilon(r) = -1 \).

8. **Conclusion:**
   - The function \( f \) can be expressed as:
     \[
     f(kp + r) = \epsilon(r) (kp + r)
     \]
     where \( \epsilon(r) \in \{-1, 1\} \) and depends on the value of \( r \).

The final answer is \( \boxed{ f(kp + r) = \epsilon(r) (kp + r) } \) where \( \epsilon(r) \in \{-1, 1\} \).