These are derived (see e.g. the relevant entry on 大辞林第三版) from the following:
which are all adjectival nouns, so using に after them is simply a remnant of this original usage. While this will no doubt seem counter-intuitive to most, more likely than not, it is in fact the な after them that has been eliminated in the past, i.e. the words have likely evolved in the following fashion:
このよう な → （こんよ な）→ （こんや な） → こんな
な → こんな
/kono joː na/ → (/kon:jo na/) →(/kon:ja na/) → /konːna
na/ (eliminated) → /konːna/
No solid evidence exists as to what the intermediate form(s) in this transformation actually was/were, assuming there even was any intermediate, so the forms in the brackets are purely speculative. The reason why な would naturally be removed at the final step is simply due to the fact that languages in general tend to simplify pronunciation over time, especially so as to eliminate redundant sounds. In addition, it is also entirely possible that「こんな」,「そんな」,「あんな」and「どんな」appeared spontaneously, as a form of ancient “slang”, without any intermediate form, i.e. directly taking a leap from「～の様」to「～んな」.
Taking「この様」as an example, the original meaning is something to the effect of “the way this appears”. This could be literally in terms of external appearance or figuratively, as in “the way things appear to be (here)” or "the way things appear to be (regarding this)". Similarly, the 「～な」 form could be defined as “such” and the 「～に」 form as “like this”, “in such way” or “in a way that appears (to be) so” or something to that effect. Similar expressions include
which correspond to「この様（な・の）」,「その様（な・の）」and「どの様（な・の）」respectively (no similar form exists for「あの様」). These are used mainly in written form, though, except for 然様 which sees some use in formal speech.
In the comments, Eiríkr Útlendi previously voiced support for the following hypothesis as a more likely route of evolution from「～の様な」to「～んな」:
/kono joː na/ → (/konːjona/) → /konːna/
この様な → （こんよな） → こんな
Now, since some seem to have misunderstood (based on the upvote/downvote trends), and since he did not mention this in his comment, it should be stated clearly that this is only a hypothesis, and as with the one I introduced at the beginning of this post, no solid evidence exists that would support this line of reasoning. On the contrary, this hypothesis, while admittedly plausible (since it gives a "path of least resistance" for the development based on pronunciation), has some clear weaknesses that ultimately make it appear much less likely than the one I gave above. Namely:
- こんな、そんな、あんな and どんな are used as adjectival nouns, i.e. synonymously with their「～の様」counterparts, like in 「あの日の天気もこんなだった」→「あの日の天気もこの様だった」. If they were indeed derived from the「～の様な」versions, this would necessitate an additional step of generalization of usage for these circumstances, which seems much more unlikely than the additional leap required in the above よう→や→な conversion sequence compared to the ような→よな→な one.
- Related to 1., but very much worth emphasizing: the short forms can be used with に. Given how Japanese grammar works, this type of development would be extremely unlikely under any circumstances if the な had originally been treated like a particle, whereas this would make perfect sense if these forms were treated like nouns from the very beginning, that is if they were directly derived from the「～の様」versions instead.
If we assume that they did, indeed, evolve from the「～の様な」version, there seems to be little reason why similar versions for「～の様に」would not have been created, i.e..:「この様に → こんよに → こんに」or "/kono joː ni/ → */konːjoni/ → /konːni/". After all, these would have been derived via the exact same mechanism – in fact, it seems obvious that the people who first started using「こんよな」 (assuming that this intermediate existed at some point) would almost certainly have simultaneously coined「こんよに」as well, and the same would apply to the final forms, 「こんな」 and 「こんに」. While it may not seem so for the uninitiated, a linguist would indeed treat this as something of a puzzle: the people who adopted these forms were logical enough to adopt similar forms for all of the「～の様」 forms; it would go against reason that they then would not apply similar logic to shorten the「～に」forms as well. It is possible that this form was simply deemed unnecessary at the time「こんな」and the rest where coined, but why, then, would these words later have gained the rather awkward (see 2.)「～んなに」form? If the「～んに」forms indeed were unnecessary, it is exceedingly challenging to justify this later development. All of this is easily explained if it is simply assumed that「こんな」and the rest of the series where derived directly from their「～の様」analogues; since currently they are all used exactly in the same way as the「～の様」form which is why we have「こんなに」＝「この様に」, for example, based on this hypothesis there would be absolutely no mystery even if nothing like「こんに」would ever have existed.
I checked some dictionary sources（広辞苑第六版、大辞林第三版、日本国語大辞典、明鏡国語辞典第二版、新明解国語辞典第五版 as well as 学研古語辞典）but none of them listed こんよ（な）、このよ（な）、こんや（な） or こん（に） (nor did any of them hint at archaic usage of such) nor additional information regarding the derivation of these words. However, if an intermediate had existed at some point (which would support the simpler pronunciation-based hypothesis), it would be very likely that some records of this would still exist. Yet there is none, indicating that if they did exist at some point, they disappeared so quickly as to leave little to no identifiable records (= unlikely). This makes the “no intermediate” hypothesis seem significantly more credible, and equivalently casts a shadow of doubt on all hypotheses that are simply based on finding some "path of least resistance" for the development of the pronunciation of the words.
In conclusion, given the available evidence, it is highly likely that the 「～んな」forms were derived directly from their「～の様」counterparts and not from their「～の様な」derivatives. However, there is no solid evidence to prove this, and it seems unlikely that any additional clues on this matter will surface any time soon.