Games are generally supposed to be challenging. But there are many different ways to achieve difficulty, and some lead to more frustration than fun. Here I'm going to talk about some bad ways to achieve difficulty. (Note that I'll stick to action games for the most part.)
Increasing the punishment for making a mistake beyond a reasonabale degree. For example, a bad designer might pit you against enemies that kill you in one hit, while you need several hits to kill them. But this is a very frustrating form of difficulty. A better idea would be to make the enemies do less damage on a single hit, but make their attacks harder to dodge, so that the player gets hit more often. It's still equally hard, but it feels better because you're not being instantly killed by a single mistake. If you made a lot of mistakes to get killed, it feels more like you deserve to fail than it does if you mess up once after a minute of immaculate play.
Time limits can be a form of this as well. The underlying idea is that instead of giving the player almost no room for mistakes in your challenge, it's better to make the mistakes easier to make. For health bars, I'd say a rule of thumb is that no enemy attack should take more than half the player's life. Exceptions can be made with good reason.
Inversely, making enemies hard by giving them unreasonable amounts of health is a bad idea. Repetition is boring. We can all agree on that. And giving enemies enormous health bars leads to repetition in two ways: not only does it force the player to tangle with the same move pattern for longer, but also it means more lost progress if the player loses. Instead, make the enemy more dangerous while you're fighting them, but don't force the player to do it for as long.
Expecting the player to know something they have no reasonable way of figuring out. Common forms:
Enemy attacks that require a specific counterplay but there's no way to validly know what that counterplay is without already knowing the enemy's move set.
A frequent cause of this is requiring you to read an enemy's physical sprite movements to know what attack is coming in time to dodge it. The problem is that video games worlds aren't bound by real-life physics, so it's often not possible for even the most attentive and smartest player to correctly infer how they should dodge an attack they haven't seen before. The safest way to avoid this is clearly teaching the player what means what (or at least allowing them to practice it in a situation where there are no consequences for failure).
Every Dark Souls game relies on this. The recently-released Sekiro is particularly bad. So I jump off a ledge and find myself in a surprise boss fight against a twelve-foot tall man on a twelve-foot tall horse with a halberd as big as my body. The rational instinct is "yikes, I wasn't prepared for this and I need to escape" (all surprise bosses up to this point have allowed fleeing the arena.) As I search for a way out that isn't magically blocked by a fog gate that wasn't there before, Gyoubu charges at me and I rationally assume I need to dodge to the side to avoid being plowed to death by the horse. Nope; he hits me the spear. I died before I even tried to attack him because each failure to dodge was more proof that I wasn't prepared for this fight and I needed to find a way out. Well apparently the solution is to block him. That's right; I can stand my ground and block this giant man with a weapon that should have enough force to send me flying. And the horse magically never plows me because then the fight would work the way physics and logic say it should work instead of the way the designers decided it should work without telling me.
So lesson learned, you can block basically anything in this game. Momentum is irrelevant. It's BS that I died that one time but okay. I get to this apparently normal human samurai later and... what? His attacks just penetrate my blocks? How the hell was I supposed to know that?
Super secret preconditions that must be set up to remove a boss's near-invincibility (Mytha the Baneful Queen, from Dark Souls 2).
You fight two bosses at once and focus your attacks on one of them only to find that if they don't die at the same time the remaining one heals the dead one to full health (Throne Watcher & Throne Defender, also Dark Souls 2).
Punishing the player for dying. As if having to restart the level wasn't enough of a punishment, some designers feel the need to do things like not return consumable items used on the last try, shrink the player's health bar each time they die (Dark Souls 2), de-level the player's character, or similar. The game should not get harder when you lose, for god's sake! It does not take a genius to figure this out!
I don't think any developer does this intentionally, but I'll say it anyway: having bad camera angles or sprites and animations that don't reflect the actual hitboxes of attacks.
Making the controls hard to use. For example, requiring the player to rotate a thumbstick more than 90° but less than 180°. It's fun when you lose a fight because you weren't skilled enough, but it's not fun when you lose a fight because your finger movements weren't exact enough. One of the main advantages of video games over sports is that they make your real life body not matter. We need to capitalize on that advantage.
Now that we've been through all that, you might be saying, "But Yujiri, you just crossed out almost all the possible ways of making a game harder! Is making the enemy attacks harder to dodge really the only thing I'm allowed to do?". No. In fact I only even mentioned that first because it was such a direct replacement for what I was criticizing.
Obviously, one of the most satisfying forms of difficulty in pretty much any type of game is smarter enemies. But that's very hard. Most AAA RTS games get as far as the second-hardest difficulty (which usually gets pwned by any competent human) using this alone and then for the hardest one give the computer a ludicrous resource boost.
I should also clarify that artificial or numeric difficulty (the first two points I criticized) are only bad in excess. Making the enemies too statistically weak can actually be a flaw of its own. It can make the player feel like the game is slanted in their favor, which ruins the feeling of pride when you win.
Another thing you can do is make the game run faster. This forces the player to think faster (increasing the challenge of mastering the depth you already have) as well as time button presses more exactly. Obviously this can only be taken to a cerain point before it becomes unrealistic for a human to do it, but I think a lot of games could do with running faster. In particular Dark Souls (and Sekiro) was the perfect game to make use of this mechanic. Skilled Dark Souls players have sometimes completed challenge runs of the game with a level 1 character and without dying or similar restrictions. The game could have been a lot nicer for those players by just including speed options so they could raise the difficulty without having to self-impose badly designed forms of it (there is a mod for Sekiro that does this). Of course, with this method you also have to worry about performance limitations, depending on the platform and the game. I don't have the information to know if that was a legitimate excuse in Dark Souls's case.
If you push all of those factors to their limits and your game is still too easy, then it just doesn't have enough mechanical depth and you need to rethink the core design.
Strategy games do warrant some discussion. For asymmetric strategy games where you need to go harder than your AI coding skills can achieve, one thing you can do is make the AI predictable. If the game is possible because the AI is stupid, that's inherently kind of lame, but if it's at least stupid in predictable ways, then the player can exploit it, creating more room for skill and allowing you to get away with a higher degree of numeric difficulty.