It’s a common mistake for beginning players to develop their attacks, but not their defense. You need both. The problem comes about because a beginning player usually starts out learning to hit forehands and backhands, and once developed, these are primarily offensive shots. These are important shots when attacking, but what about when the opponent attacks?
Against many attacks, you can counter-attack. However, this can lead to some rather wild, low percentage shots. A little defense would be the better option. So it's important to learn to defend, such as blocking.
It doesn't have to be passive blocking; you can block aggressively. Take the ball quick off the bounce and quick-hit the ball to the opponent's wide corners or middle (the transition point between forehand and backhand), and keep moving him around these three spots, and you'll often force a miss or weaker shot you can attack. The most common way to beat an attacker is to attack first, but if you can block, you take much of that advantage away, and turn your defense into a transition back to your own attack.
Many table tennis drills involve one player attacking, the other blocking. When you are the blocker in such a drill, take this just as seriously as you would when you are attacking. Many players treat drills as something where the two players take turns drilling. Never!!! A drill is a two-way thing, and whatever your opponent is doing, you are drilling against it. You learn to block by blocking, and the best time to do that is by focusing on your blocking in drills. Work on precision - if you learn to block the ball accurately and consistently in drills, this will show up in matches as well. You can also practice advanced variations, such as topspin blocks (i.e. mini-loops), dead blocks, and chop and sidespin blocks.
You can also learn other defensive shots, such as lobbing, fishing and chopping. Lobbing is a high defensive topspin shot, usually done off a smash. It's often a desperation tactic, but in the hands of an expert, it's a valuable way to win a few points that otherwise would be lost. Fishing is a lower defensive topspin shot, where you keep the ball roughly one to four feet high. Fishing defense is central to many players' games, especially loopers, who play off the table and need an off-table shot to defend with. Fishing and lobbing, done at the higher levels (where the ball goes deep with topspin and sometimes sidespin), are basically just defensive loops. They are a bit more advanced than blocking, but if you have mobility off the table, they are valuable shots to have. Fishing and lobbing tend to go together as most players who do one do the other as well.
Chopping is a more specialized defense, and while I don’t recommend most offensive players to back off the table and try to chop down an opponent, it’s valuable to be able to throw in a chop now and then, especially on the backhand when you are out of position. Plus, of course, many players play a chopping style, in which case chopping is central to their game.
Note that I don’t include pushing as a defensive shot. A defensive shot is done against an incoming offensive shot. A push is more a sparring backspin shot against an incoming non-offensive shot, such as a backspin or no-spin push or serve. If done poorly, it’s a defensive shot, but that’s because it’s done poorly. It should be more of a neutral shot.
Many years ago Cheng Yinghua (former Chinese team member, once the #1 player in the U.S. for a decade as he won Men's Singles at four Nationals and two Opens while making the 2000 Olympic team) said that the biggest weakness of most top U.S. players were their fundamentals, in particular their defense. When these players attacked against the best players in the U.S. at the time - Cheng, David Zhuang, Ilija Lupulesku - they faced great defense (blocking by the first two, fishing and lobbing by Lupulesku), and struggled to win a point. When these three attacked, opponent after opponent would crumble due to their lack of defensive skills This is true at all levels. So learn to play defense, and make your opponents be the ones who crumble when the other player attacks.