A secondary answer is that it was the Levites' responsibility to have properly moved the ark. They are the one's given charge of it in the Law (specifically the Kohathites, Num 3:27-31), and they are the one's then responsible to see that it is properly done. Indeed, Num 4:15 explicitly states that (bold added)
And when Aaron and his sons have finished covering the sanctuary and all the furnishings of the sanctuary, when the camp is set to go, then the sons of Kohath shall come to carry them; but they shall not touch any holy thing, lest they die.
So only the sons of Aaron, the priests, could actually touch the most holy of the objects. They had to pack them up (and cover the ark), then the Kohathites would bear the ark on the poles. It should be obvious how this command relates directly to the violation of Uzza (especially if he is in fact a Levite and one of the family of Kohath, which is discussed some below).
Additionally, there were not even kings in Israel at the time the Levites gained this responsibility. So in short, the Levites should have insisted to the king that it be moved properly.
Now it is unclear (from the text) whether or not Abinadab and his sons (per 2 Sam 6:3), Uzza and Ahio, are Levites or not. There is strong implication such is the case given that they did become the caretakers of the ark and his son Eleazar was "consecrated" to keep it (1 Sam 7:1), and that Levitical lineage is what the much later Jewish historian Josephus believed (Antiquities 6.18):
In this city lived one Abinadab, by birth a Levite, and who was greatly commended for his righteous and religious course of life; so they brought the ark to his house, as to a place fit for God himself to abide in, since therein did inhabit a righteous man. His sons also ministered to the divine service at the ark, and were the principal curators of it for twenty years; for so many years it continued in Kirjath-jearim, having been but four months with the Philistines.
If they were Levites, then they would have been directly responsible for having properly moved the ark, and all the more cause for God to have struck Uzza. But even if they were merely Israelites of another tribe, who had been watching over the ark, David had called the Levites and priests together on this endeavor (1 Chr 13:2), so someone from that group should have informed them of the proper means and stepped up to be the one's who transported the ark.
A tertiary answer is that it was in Abinadab's house for 20 years (and 7 months with the Philistines per 1 Sam 6:1, and however long [probably short] with the people of Beth Shemesh in 1 Sam 6:13-21); so a total of nearly 21 years since the ark was last moved. Even then, it actually does not say how Eli's sons moved the ark when they brought it to battle against the Philistines (1 Sam 4:3-6), but prior to that incident, it would seem the ark rested in Shiloh for a few hundred years (the period of the judges after Joshua, to Samuel, per Josh 18:1 to 1 Sam 1:3).
People forget what they do not use (i.e. no one had moved the ark for 20 years at least, and possibly not moved it correctly for a centuries; in either case, though especially the latter, many had forgotten how).
David was roughly 37 1/2 years old at the time the ark was moved (30 years old at beginning of reign, 7 1/2 years in Hebron before moving to Jerusalem; 2 Sam 5:4-5;), for it was attempted soon after he moved his reign to Jerusalem (simply based on the fact that it is the next ). So what you assert is likely not the case:
Since David had been a contemporary of Samuel the prophet he was familiar with the transportation of the ark.
Especially given the fact that the text testifies otherwise, for after the incident of Uzza, 2 Sam 6:9 declares:
David was afraid of the LORD that day; and he said, “How can the ark of the LORD come to me?”
That seems a pretty strong indication that during the first attempt to move it, David was unaware of the proper means to transport it. He apparently searches out the answer to that question and finds it during the three months the ark is at Obed-Edom's house (2 Sam 6:11), for as you note, during the second move there are "those bearing the ark" (2 Sam 6:13), and David asserts (1 Chr 15:2):
Then David said, “No one may carry the ark of God but the Levites, for the LORD has chosen them to carry the ark of God and to minister before Him forever.”
And he recognizes the error from the previous attempt (1 Chr 15:13, bold added):
"For because you [priests and Levites] did not do it the first time, the LORD our God broke out against us, because we did not consult Him about the proper order.”
That final statement that I bolded of David's gives the clear statement that the first time they had not looked into how to move the ark. This implies no one knew how, until it was searched out.
So David's only "fault" in the first instance was not having insured the ark was moved properly, but the text implies he was not even aware there was an issue about how to move it until after the incident occurred.