One often arrives at delicate points when trying to find a literal connection between mathematical and physical approaches to problems. As G. Smith already commented, the important aspect here is modeling. Roughly, this goes in three steps:
- You have a real (physical) system and you map it to some mathematical structure.
- You analyze the properties of the mathematical structure and find some connections.
- In the end, you map the result back to reality, giving you a prediction.
Typical example: You want to calculate the path of an arrow and map its position to a position and momentum variable in sapcetime with time evolution embedded in Newtonian laws. You do some math manipulations and get, say, the coordinates describing the impact point of your arrow. You conclude from these coordinates (which are numbers) where the arrow will hit (which is a real positon and someone might go ouch).
The problematic bit about your question is that it asks about a way to intuitively understand some math without stating from which physical theory the math should come from. When you talk about apples squared and adding apples and bananas, you are implying there is some canonical (standard) way to incorporate a measurement quantity like "apple" into existing theories of physics. But that isn't the case. You are at liberty to define what you would consider the unit of apple to be in your model.
To make this more concrete, let's challenge the everybody-learned-this-in-school statement you started out from. You say that addition must use the same units. But that's not necessarily true. As long as you haven't specified how you describe your quantities, there are ample options where you can add apples and bananas. If you say that the tuple
$$Q = \begin{pmatrix} N_A \\ N_B \end{pmatrix}$$
describes the number of apples $N_A$ and bananas $N_B$ in a box, then you can easily add them by the usual vector space addition,
$$Q + Q' = \begin{pmatrix} N_A \\ N_B \end{pmatrix} + \begin{pmatrix} N_A' \\ N_B' \end{pmatrix} = \begin{pmatrix} N_A + N_A' \\ N_B + N_B' \end{pmatrix}.$$
This isn't meant to say that the statement "You can't add apples and bananas" is wrong. Understood in the typical intuitive way, it is quite right. It just goes to say that the connection between mathematical formalism and reality isn't "obvious" or that all alternatives must be arcane bullshit. The tuple-notation above is basically what any spreadsheet table does, and it is essential in bookkeeping.
That said, there is no physical reality to "apple$^2$" because there is no theory that fixes its meaning. This makes answering this question hard - you can define some sense in which the unit apple can mean something, as Agnius Vasiliauskas did by using apple as a (possibly anisotropic) length unit, just like the size of some bishop's feet were used as a length unit in the middle ages. But that isn't the "counting" unit for apples. As others already pointed out, there are situations where a squared quantity has a clear-cut meaning. That often comes from proportionality concepts. The mass squared appears in gravitational laws because doubling either of the masses will double the strength of the force. And doubling the distance will cut the force by four. If you were to change the measurement units, then the numbers in front of them would have to change, too. In that way, when we leave the units in the equation, we have an intuitive and straightforward way to calculate how the numbers change if we apply a different unit convention.