Question: Lately I've started learning some basic music theory and I have been trying to rationalize some of the interesting chords I have heard of from famous pieces. Here is an example of which I am not sure if my understanding is correct.

Below are bar 11-12 from Mozart's Piano Sonata No.11 in A major, K.331. I have marked the chords using Roman numeral notations.

[![score](https://i.stack.imgur.com/Px8LY.png)](https://i.stack.imgur.com/Px8LY.png)

The blue text shows a naive marking. To me the ♯iv° chord gives a warm and sweet shifting feeling. I found that if I think of it as an applied chord (by tonicizing V) then the last three chords becomes a (vii° - IV - I) progression. If this is the case I was wondering how come the IV chord, as a pre-dominant chord, appears *after* the dominant chord vii° instead of before it? Why would the progression still sound inevitable when the strong dominant -> tonic progression is broken? 

---

Per @Dekkadeci's answer I revised the analysis as follows. The final three-chord progression simultaneously resolves two tension (cadential I chord to V, and on the V scale, dominant vii° to tonic I.

[![score2](https://i.stack.imgur.com/mf2pZ.png)](https://i.stack.imgur.com/mf2pZ.png)

Answer: 
You ask how to rationalise the progression. Here's how. It's a bare-bones B7, the dominant of the following chord, E, to which it resolves, delayed by a suspension. There's no room for all the notes of B7 in 3-part texture, but that's no reason to analyse it as something unnecessarily complicated.
I'm not exactly qualified to give you the classical language answer but conceptually I hope I point you in the right direction. I had to look up the difference between an appogiatura, a suspension etc. etc. In Jazz we tend to call all resolving non chord tones suspensions, but I'm pretty sure in classical music a suspension has to come directly from the previous chord rather than be just any resolving non chord tone (which I believe in classical is strictly an "apogiatura".) I could be wrong with my terminology here, but hopefully that won't bog you down; the point is I'm talking about resolving non-chord tones!

Anyway, you are right that the diminished chord is absolutely tonicizing the V. The reason the A chord in its second inversion works here is that it ends up sounding like a suspended E chord, rather than an A chord. 

The diminished chord resolves to the E in the bass, and then the the A and C# are apogiatura that resolve downwards to an E chord (it has a certain plagal cadence feel to it, but it's really an apogiatura.). To give an example without modulation, check this crappy midi thing I just whipped up <http://onlinesequencer.net/425519> . It's progression ending in a perfect cadence in A, but the ending I chord has resolving D and F# in it.

To illustrate the point, I added an F# apogiatura to the passage you gave. <http://onlinesequencer.net/425524>. The point is, an F# obviously isn't in an A chord, but doesn't sound at all out of place here; it's performing the same function as the A and the C# resolving downwards to the E chord.

You could also put a B above the E in the bass and not change the harmony (although it's a bit of an ugly voicing).