Did knights actually slash/swing with their swords in combat like in games such as Dark Souls and Skyrim, or did they attack each other at a distance like fencing?
Yes. Between historical art, the design of the blades and historical treatises which were effectively manuals to help learn stances and certain techniques for swordsmanship we can pretty confidently say that knights did both slash and thrust with swords. Throughout the medieval period as factors such as armour evolved we see a general trend in blades being generally designed more with thrusting in mind becoming more common as the medieval period went on based on blade design. On the other hand relatively few video games are perfectly realistic representations of historical combat.
There's numerous reasons why medieval combat might blade out differently to modern fencing but a big one for fencing with foils which you will probably see most often and their larger cousins epees is because it doesn't count as a hit. Only sabres allow for contact with the edge of the blade to be considered a hit because the other two are designed based of the very light and relatively flexible much later small swords which were extremely specialised as thrusting blades with that lack of weighting and the often triangular blade design giving them a limited ability to chop. Additionally in foil events hits are limited to the abdomen to be counted.
Then you have to consider the objectives of striking your opponent are different. Fencing is just a sport, contact doesn't have to be a well aimed hard blow, no one is trying to hurt each other. A knight meanwhile is trying to cut their opponent down, when they slashed it needed to be with enough force to cut through clothing and potentially soft armour like a light gambeson, slice through flesh and potentially looking to break bones at time like if you struck the wrist. Their thrusts likewise might have be either hard and straight enough that they could drive the blade through gambeson and maybe with enough force mail or with heavier armour like plate the blade had to be designed to be able to be thrusted through a gap in the plates if the user was skilled enough to do so and of course again had to be done so with enough force to drive it into their enemy's body. The other thing with fencing is that only the first contact counts, if you have two fencers make contact in quick succession the one you touches first wins the exchange, but if you were in a real fight people usually aren't going to topple over instantly, they're still hopped up on adrenaline and even if you get a killing blow that sends them very rapidly into shock and they die from something like a thrust through the heart if their blade is already swinging it has momentum and if you've left yourself open to that its still going to be a threat. As such a knight is going to be looking to be trying to get in a position where they can make their attack ideally while still guarding themselves from their enemy's strike.
Then there's blade design. Sabres are the most like medieval blades. As i said earlier while towards the late medieval period blades were more often designed for thrusting in mind as the cost of armour became small enough that lighter forms of armour became increasingly affordable for more soldiers to wear it and heavier plate armour emerged that necessitated precision thrusting. But compared to the two thrusting blades used in fencing medieval thrusting blades needed to have a lot less flex in them to make it easier to smoothly slip the blade through the gaps in that plate. Additionally in terms of weight medieval you're usually talking between one kilogram and two in something like a Type XIV, most fencing blades are well under half a kilogram. They're not designed so that like a knights sword that the user should be able to generate a lot of force behind their blows and its difficult to parry a much heavier blade than the one you're using.
You also have to consider the dynamics produced with things like shields. When fighting with a single handed sword you'd usually have a shield in the other hand. While a well placed thrust can get round a shield of course you've got to work to get through your opponents guard while doing that without being killed, particularly where the enemy has people fighting to the left and right of them and if you step too far forwards they're likely to cut you down. So having a wide range of angles of attack you can choose from is a useful thing to be able to do. More options means more potential openings you can attempt to exploit.
What games generally do wrong most commonly among other things is they exaggerate the motions people are making. A lot of swirling and twirling. Bringing a sword right back before striking with it like you're playing rounders or something. That kind of thing would be much too easy to see coming. Mostly because naturally someone's ability to see, understand and respond in a game is a little slower than in real life and because a game can't really expect its players to be able to do things like notice where their enemy's eyes are going and more subtle movements of their wrist to predict exactly where a strike is going. Rather like a fencer particularly if you weren't also using a shield you'd have your weapon in a guard position much like a modern fencer that allows you to quickly move between offense and defence smoothly, just that particularly earlier in the period and when fighting an unarmoured opponent or likely armoured opponent a knight would include more slashing in their fighting style compared to foil and epee fencers.
If you'd like to get a better idea of what this would look like HEMA, Historical European Martial Arts, is the modern sport which tends to revolve around attempting to simulate historical melee combat to the extent that's possible. You can find a lot of footage on youtube of people fighting using a variety of medieval blade types and while there are probably very few people in the world today who can fight as well as a good professional knight that'll at least give you a general idea about what this kind of combat, at least in context of a loose skirmish or duel, might look like.