Weak squares are squares on your opponent's third and fourth ranks that can't be protected by his pawns.
What are you supposed to do after attacking a weak square?

Try to get one of your pawns in a position so that it is defending the weak square, then put a knight on the square. That knight will be really hard for your opponent to get rid of.

No way to anwser that question without seeing the situation.
What if it is mate in 3 moves. Do you make defensive moves? No.
How about a chance to fork the Queen and Rook in 2 moves Do you make defensive moves? No.
One has to assess the situation and do what the situation demands to be done. If you can not determine it take your best educated guess. By this it should be a move that forces your opponent into a limited response vs another move you would have made at the time. If you still can not see anthing...... make it as complicated for him/her to make their next move.

Weak squares are squares on your opponent's third and fourth ranks that can't be protected by his pawns.
That is in the opening if you want to attack. A weak square is not limited to a specific rank. If your opponent can not control that square and can not take it away by force then it is weak.
Or i like to use another term "Tempory Weak Square" as you can own that square for a short time but long enough to do damage to your opponent. Use it as an outpost long enough to win material.

In very general terms, you either use the weak square as an infiltration point / outpost for your piece(s) or by controlling the weak square you limit the opponent's space or mobility. Again in very general terms, if you can't use it to create a weakness or attack anything then it's useless as an outpost, and if the opponent can ignore its restricting effects then it's useless to control for space/mobility reasons.
In practice it's not always so obvious though. Occupying an outpost may not help you target anything in the present position, but in the future it may be useful so it's good to occupy right away. Or it may be good in the present, but it allows counter play that gives your opponent compensation. As an easy example for a long time the sveshnikov Sicilian was considered bad for giving up d5 and making a backward pawn on d6. So white controls and occupies d5... this is not bad play for white, but black has counter play so overall it's not good or bad, it's just a game of chess.
So in summary sometimes it's good, sometimes it's bad. Sometimes you'll think it's good but it's bad, and sometimes you'll think it's bad but it's good. And finally sometimes it's neither bad nor good, it's just dynamic. Chess is simple huh?

I think that after the opening, we are supposed to attack the weak squares in the huge center with our pieces. I might be wrong about this part but I'm pretty sure this is what you do. I'm confused about what you do after this part. If someone could explain this, that would help a lot.
Stick with the basics. Control the center then attack the wing or open files or ranks or diagonals. Win material. Stay away from meaningless moves(public enemy # 1). Check for checks, check if you need to be defensive and check what is your opponents best move.
The board changes constantly. Which wing can you attack better? Are your pieces active enough to finish the attack on the wing? If not your going to have big problems later when they recover.
If you know the strengths and weakness of your opening more than likely will know what your goals are in the Middle Game. Place your key pieces in position to reach the line you wish to attack. Each attacking line varies. With e4 you know it is going to be more than likely a game where it leads to the center being open around moves 10-20. Each side will try fierce attacks on the King side castle position. So now position will be stable ..... so look to trade off pieces by forks, pins and other tactics. I would say learn how to attack an castled position as just the threat alone may make a position somewhere else weak enough to win material.

If you want direction in your game, study pawn structure plans aka Pawn Structure Chess by Andy Soltis. If that's too high level for you focus on getting your knights into the 5th and 6th ranks, your bishops on long open diagonals targeting an unsupported pawn or taking up space, getting your rooks on open or half open files and the 7th rank, and simultaneously prevent your opponent from doing any of the things I just listed.

Stick a knight in that square, and hold it there with everything you have!
Nothing like chasing the Queen around and capture her 3:oo am ....
Sorry game to serious but you get the point. If the King is not a target the Queen is a target. Once the queen is off the board and you still have yours their country is for the taking.
Sorry again losing focus. Some piece can be captured somewhere just have to take your time and find where. This takes practice and no matter how much you read or comments we leave ....you have to practice this in your games. Chess is about 2 basic things win the king or win the other pieces.

' Weak squares' or colour complexes are a horrible thing for beginners to focus on IMO. Far too abstract and sometimes the benefits aren't immediate.

Yeah, strategic ideas are mostly a pitfall for newer players. Material and mobility / activity is all you really need to focus on. All the advanced fancy strategic ideas can be derived from these basics. At the board most of your energy should be spent on identifying your opponent's current threats, and the threats they can make on the next move. Really that's most of your work. If you identify there are no threats, or that the threats that do exist can be ignored, see if you can win something. If you can't win material, then try to be more mobile, more active. A rook on an open file a bishop on a long diagonal, centralized pieces, that sort of thing.

One trick you can do, if its a weak pawn, pile everything you got on it. Let your opponent pile every piece he has defending it. Then, at the right moment, forget about that pawn, shift everything over, and attack something else!
If you plan it right, your opponent will trip over each other, and be unable to reach the new target in time to defend it.
I've seen Karpov use this trick a lot.

One trick you can do, if its a weak pawn, pile everything you got on it. Let your opponent pile every piece he has defending it. Then, at the right moment, forget about that pawn, shift everything over, and attack something else!
If you plan it right, your opponent will trip over each other, and be unable to reach the new target in time to defend it.
I've seen Karpov use this trick a lot.
Sounds like a good one. You actually made it make sense.
I think that after the opening, we are supposed to attack the weak squares in the huge center with our pieces. I might be wrong about this part but I'm pretty sure this is what you do. I'm confused about what you do after this part. If someone could explain this, that would help a lot.