The XY problem: Avoid focusing on the attempted solution rather than the actual problem. People don't want a faster horse. They want to get to their destination faster.
Ever been stuck in a situation where you thought you had a solution to a problem, but only after asking for help to debug your solution you found out your solution is unnecessary because there's a much better and stupidly simple way to solve the same problem?
This is the XY problem. We believe our solution Y to problem X would work. So when running into trouble when solving X, we ask about your particular solution Y instead of giving the context of X. In other words, we focus on the attempted solution rather than the actual problem.
Think of it like the famous apocryphal Henry Ford quote: "If I had asked people what they wanted, they would have said faster horses." We can spend our whole life figuring out how to make the horse run faster through some genetic modification. However, the real issue is people want to get to their destination faster. Therefore, instead of getting fixated on making horses faster (solution Y), he came up with a better solution - the car (problem X). Another quote from Theodore Levitt is also a good example: "People don't want to buy a quarter-inch drill. They want a quarter-inch hole!"
To avoid falling into the trap of the XY problem, we should provide sufficient context about the problem when seeking help for a proposed solution. While unnecessary details should be avoided, we should communicate the essence of the problem.