Even after launching so many space missions, including the one which led Man to the Moon (Apollo 11, July 1969), NASA made several mistakes even in the space programs that followed. For e.g. Space Shuttle Columbia disaster, Challenger disaster. The failures were later easily debunked. For e.g. by Richard Feynman. Didn't NASA learn from the Human Spaceflight programmes they did previously like Apollo series of missions? Also, Why isn't NASA going back to Moon if they have the technology to do so?
This is a strange question, but it is worth answering. The ultimate answer is:
Space is hard. But let's unpack that.
There were many, many factors that led to the various failures and accidents. Some of them were a simple lack of understanding during the design phase - space is hard, that's not a joke but a reality. Simply put, we don't understand how things in space work to a huge degree, although we are getting a lot better. As an example from the early space program, we had to send the Pioneer probes out to Jupiter because we literally had no idea whether or not the asteroid belt was passable. You don't know until you try, and everything is a first in space.
This is also common on the ISS even now. For instance, we have had several failures of seemingly simple systems, such as toilets. It's not because we don't know how to make a toilet on Earth, it's because the demands for a toilet in space, in zero-g, with recycling and waste demands being so high make it nearly impossible to make a good toilet on the first few tries. Basically, as before, we don't know until we try. We simply needed to make a prototype toilet and run it for years until it broke to find out how and why.
Then there are the failures due to an obvious oversight of management. Challenger is a big one here - engineers were screaming that the shuttle shouldn't launch but management ignored them. Even at NASA you can't protect against stupid, and if someone makes a bad call then someone makes a bad call.
Some of these failures are so perversely hidden that it can take years to figure out what really went wrong. Take Apollo 13 as an example. Yes, the ultimate cause was the destruction of the O2 tank due to a melted heater, but what really caused that was a decision to use a higher voltage on the launch pad than on the spacecraft, and to not fix that before launch. That in and of itself wasn't important except that a failed test made them use that heater to boil off the O2. Even that wasn't a big deal, except the internal thermometer reading only went up to 80F or something (and it goes on. Read "lost moon" to get more information there). The point is, the failure happened at so many levels because of a seemingly inconsequential thing that had worked many times before.
So, no, no conspiracy, just mistakes.
To answer the second question: we don't have the technology to get to the moon, actually. We didn't really have it in the 1960s - those moon landings were dangerous. Scary dangerous. The fact that "only" two missions suffered from catastrophic failure is a testament to luck, not engineering ingenuity. Also, political will very much didn't swing in favour of a return to beyond low-Earth orbit destinations. Support for the moon landings was actually really low, and has been for a while. So to that one, it's basically because we don't want to, as a society, not because we couldn't do it if we wanted to.
During the Apollo era (1967-1972), 4 NASA astronauts died during training or test flight. Those 4 brave people were the Apollo 1 crew, Gus Grissom, Ed White, and Roger B. Chaffee. The fourth astronaut was Clifton C. Williams who died flying a training jet.
However no NASA astronaut died in spaceflight during the Apollo era. Unfortunately, there were fatalities in spaceflight for the cosmonauts during the Apollo era such as Soyuz 1 and 11. There were technical malfunctions as well such as Apollo 13, but luckily there were no fatalities.
After the Apollo era, 14 astronauts died during spaceflight. 7 from Challenger and 7 from Columbia. The Apollo missions were very different from the Space Shuttle. One was designed to go and land on the moon and sustain 3 people for 8 days, and the other was designed to stay in LEO, return like an airplane to a specific location, be refurbish-able, and sustain 7 people for about 16 days.
You can find the list of all Spaceflight-related accidents here.
The Challenger mission failed because of the O-rings, which contained the pressure build-up of the hot gas in the SRB and caused it to explode and tear apart from the fuel tank. The cold temperatures at launch caused the O-ring to harden and preventing the O-rings to open, thus the pressure built-up. This was the first time NASA used the O-rings so they didn't learn anything from the Apollo program.
Columbia was more of a "human error" accident compared to Challenger which was a "engineering" error. A block of foam struck the Shuttle's heat shield under the wing during launch and damaged it, which caused it to disintegrate during re-entry.
So in summary, NASA didn't learn anything from the Apollo missions which could've prevented the shuttle disasters because this was new technology that hadn't been developed in the Apollo era.
Some things NASA did learn was to not have an environment of 100% oxygen as that can easily start a fire, and to make thicker walls to handle increased pressure. All of this was learned from Apollo 1.
The answer to your side-question,
Why isn't NASA going back to Moon if they have the technology to do so?
I've noticed that you might be a conspiracy theorist so I might've wasted my time. We can do another mission such as Apollo. The only problem is that it's inefficient, very expensive, unsafe and overall not worth it. Safety standards are a lot higher now, so we need to find a safer way to get to the moon. The Saturn V has been decommissioned because it was a very costly rocket that used a lot of resources, but congress has agreed to fund the SLS as it creates jobs, but that's another topic. And we are going to the moon in a couple of years. It's called the Artemis Program which is intended to launch in 2024. There are also private-funded missions (not funded by the government like NASA ) to the moon such as Starship.