Let $a$ be a positive real number and $f:[a,\infty)\to\mathbb{C}$ a continuous function. Prove that the function $g:[a,\infty)\to\mathbb{R}$ defined by $$g(x):=x\,\int_a^x\,\frac{1}{s^2}\,\int_a^s\,t\,f(t)\,\text{d}t\,\text{d}s - \int_a^x\,\int_a^s\,f(t)\,\text{d}t\,\text{d}s\text{ for each }x\in[a,\infty)$$ is a linear function.
I wonder if there is a solution involving only directly tackling the integrals (e.g., with integration by parts and/or with swapping the order of the integrals), without differentiating $g$. My solution is to differentiate $g$ twice and show that $g''\equiv0$. If $p$ and $q$ are constants such that $$g(x)=p(x-a)+q\text{ for all }x\geq a\,,$$ then it is not difficult to see that $q=0$. It may be good to find out how the $p$ depends on $f$ and $a$.
Spoiler: The constant $p$ does not depend on $f$ and $a$---it is just $0$. Below is my solution.
Using the Leibniz Integral Rule, we obtain $$g'(x)=\int_a^x\,\frac{1}{s^2}\,\int_a^s\,t\,f(t)\,\text{d}t\,\text{d}s+\frac{1}{x}\,\int_a^x\,t\,f(t)\,\text{d}t-\int_a^x\,f(t)\,\text{d}t\,.$$ Thus, applying the Leibniz Integral Rule again yields $$g''(x)=\frac{1}{x^2}\,\int_a^x\,t\,f(t)\,\text{d}t-\frac{1}{x^2}\,\int_a^x\,t\,f(t)\,\text{d}t+f(x)-f(x)=0\,.$$ The result follows.
In fact, from this calculation, $g'(a)=0$. Therefore, $p=0$ as well. Hence, $g\equiv 0$. Consequently, we indeed have that $$x\,\int_a^x\,\frac{1}{s^2}\,\int_a^s\,t\,f(t)\,\text{d}t\,\text{d}s = \int_a^x\,\int_a^s\,f(t)\,\text{d}t\,\text{d}s\text{ for every }x\in[a,\infty)\,.$$
This equality can be obtained easily by integration by parts or switching the order of the two integrals.
I will showcase the order switch.
We can draw the domain of integration on the s-t plane or purely algebraically conclude that the reversing the order changes the limits as follows:
$\int_{s=a}^xds\int^s_{t=a}dt=\int_{t=a}^xdt\int^x_{s=t}ds$
This allows us to perform one integral in every double integral:
$g(x)=x\int_{t=a}^xtf(t)dt\int^x_{s=t}d(-1/s)-\int_{t=a}^xdtf(t)\int^x_{s=t}ds=$
$x\int_{t=a}^xtf(t)(\frac{1}{t}-\frac{1}{x})dt-\int_{t=a}^xf(t)(x-t)dt=0$
and this concludes the proof.