How do weapon pylons attach to a fighter's wings?
The pylons are not just for weapons; the term used for the Typhoon aircraft is the Wing Pylon Station Unit (WPSU) and some of those are designed to be able to carry external fuel tanks.

Some aircraft (such as the vernerable F-4 Phantom II) had 4 wing pylons which were more or less permanently attached (unless they were defective in which case they could be replaced); certainly in the years I worked on them I never saw an aircraft without all 4 pylons.

Other aircraft (such as the Typhoon) have pylons that are not necessarily all fitted
(there are locations for up to 8 wing pylons)

Here is a fit using only 6 of the pylons and all 5 fuselage hard points:



Here is a different setup using all 8 wing pylons:



Source

The attachment is relatively simple (it has to be as it can be a hangar operation for operational fit); the pylons are physically attached with mechanical mounting and electrical connectivity (to actually operate the items being carried); the pylons that can take external tanks also have fuel feed points.

The pylons also have communication links for the aircradt to 'talk' the whatever happens to be fitted on the pylons (the data could be commands, video feed, sensor data, stores readiness - whatever is required for a particular type of store on the pylon)

It is important to note that the all the hard points are considered safety critical as you do not want to fire / jettison something when not commanded and you do want that at the appropriate time.

The inner structure of the pylons is almost completely full (very little space unused) which keeps the unit as small as possible (which enhances its ability to withstand aerodynamic forces) and as light as possible.

The electronics within the pylons are somewhat expensive as the internal temperature can be as low as -50C or lower at high altitudes; the leading edge is a low drag surface to minimise heating by air friction.

Different pylons will have slightly different attachment methods but they all need to withstand the aerodynamic forces and provide electrical and communication functionality.

Update

Here is a close up of an F35 pylon (designed for air to air weapons):



Source

The mounting bolt position is clearly shown (there is another on the other side of the pylon). The pylon fits into an acceptor slot and all the various connections are made simply by placing the pylon in the correct position and sliding it in. The direction of sliding is from the front so aerodynamic pressure keeps it in position.

Interesting fact. One fine day I was working on the flight line at RNAS Yeovilton when an american F-4 flew over; he was doing a bit of hot-dogging. The aircraft had two external wing mounted Sargent Fletcher fuel tanks and when he did a high G pullup, the tanks separated from the wing pylons and landed on a roundabout in the middle of the road.

This is one of the issues with wing pylons and stores; they impose a g limit on maneuvering or things literally break away.

I understand his boss was not at all pleased.