Prove that $f:\mathbb R^n\to\mathbb R$ is affine if and only if it is convex and concave
Let $g(x) = f(x) - f(0)$. It suffices to show that $g$ (which is also both convex and concave, and satisfies $g(0)=0$) is linear. Next, note that for $t > 1$, $x = (1/t) (tx) + (1 - 1/t) (0)$.
That should give you a good start...
I think it becomes more clear when we simply apply the definition of convexity and concavity.
From the convexity of $f$ we have for $x_1, x_2\in \mathbb{R^n}$ and $\lambda \in [0,1]$$$f((1-\lambda)x_1 + \lambda x_2) \le (1- \lambda)f(x_1)+\lambda f(x_2)$$
and similarly for concavity we have $$f((1-\lambda)x_1 + \lambda x_2) \ge (1- \lambda)f(x_1)+\lambda f(x_2)$$ Thus it follows that $$f((1-\lambda)x_1 + \lambda x_2) = (1- \lambda)f(x_1)+\lambda f(x_2)$$
We often think of $(1-\lambda)x_1 + \lambda x_2$ as a point on the line segment between $x_1$ and $x_2$. Similarly from above we can see that $f((1-\lambda)x_1 + \lambda x_2)$ lies on the line segment between $f(x_1)$ and $f(x_2)$. Since we have chosen $x_1$ and $x_2$ arbitrarily it starts to become apparent why $f$ is affine. If we recall, an affine function takes the form $ax+b$ where $a \in \mathbb{R^n}$ and $ b \in \mathbb{R}$ which is a line.