What goes wrong in the immune system that leads to autoimmune diseases
Your understanding of the process is basically correct. There are of course a lot more details to it, but that wouldn't be in the scope of the question. Do note that only T cells mature in the thymus (that's where the T comes from ^^), whereas B cells mature in lymph nodes and the spleen.

As for why autoimmunity occurs you also understood the basics, however the devil is in the details: wikipedia does have a much longer list of mechanistically different causes. While its often sufficient to explain immune recognition using 'keys' (T cell receptor / B cell receptor = antibody) and their respective 'locks' (peptides bound to MHC / antigens), the exact process of immune cell activation becomes important in autoimmunity, where cells are wrongly activated. This means that there are many possible points at which the 'security system' of the immune cell maturation can (or rather has to) fail to allow autoimmunity.

As for the cross-reactivity of cells: the difference between the binding of B cells (via antibody/B cell receptor to protein surfaces) and T cells (via T cell receptor to peptide sequences) means that in general T cells are much more likely to show cross reactivity - just because the possibility space of a 10-12aa peptide is much smaller than that of a protein surface (even though the probability is still very low).

Additionally - as stated in the comments to your question - both the immune activation pathway and the issue of cross reactivity, while principally understood, are not 'completely solved'. The immune system is insanely complex just by itself and the addition of interactions with both almost all human proteins AND proteins any kind of pathogen, mean that it will take quite a lot of time until researchers can figure out all the weird quirks caused by the 'wrong' combinations.