Consider the function \[ f(x) =
\begin{cases}
ax^2 & \text{if } x \geq a,\\
ax +2a& \text{if } x <a,
\end{cases}
\]where $a$ is some number.

What is the largest value of $a$ such that the graph of $y=f(x)$ intersects every horizontal line at least once?
For $x < a,$ the graph of $y = f(x)$ is the same as the graph of $y = ax+2a,$ which is a line with slope $a$ and which passes through the point $(a, a^2+2a).$ For $x \ge a,$ the graph of $y = f(x)$ is the same as the graph of $y = ax^2,$ which is a parabola passing through the point $(a, a^3).$

Notice that the parabola only ever takes nonnegative values. Therefore, the line portion of the graph must have positive slope, because it must intersect horizontal lines which lie below the $x-$axis. Thus, $a > 0.$

For $a > 0,$ the line portion of the graph passes through all horizontal lines with height less than or equal to $a^2+2a,$ and the parabola portion of the graph passes through all horizontal lines with height greater than or equal to $a^3.$ Therefore, all horizontal lines are covered if and only if \[a^2 + 2a \ge a^3.\]Since $ a > 0,$ we can divide by $a$ to get \[a + 2 \ge a^2,\]so $0 \ge a^2 - a - 2 = (a-2) ( a+1).$ This means that $-1 \le a \le 2,$ so the greatest possible value of $a$ is $\boxed{2}.$

The graph of $y = f(x)$ for $a = 2$ is shown below (not to scale); note how the parabola and line meet at one point: [asy]
size(8cm);
import graph;

real a =2;
draw((-5,0)--(6,0),EndArrow());
draw((0,-6)--(0,14),EndArrow());

real g(real x) {return 0.5*a*(x-a)^2+a^3;}
real f(real x) {return a*x+2*a;}

draw(graph(f,-4.6,a),BeginArrow());
draw(graph(g,a,4.5),EndArrow());

label("$f(x)$",(0,15.5));
label("$x$",(6,0),E);
dot((2,8));
[/asy]