The latch in the pic is facing the opposite direction it needs to be for correct operation. Just flip it over so the 'short foot' is facing towards the front of the gun. Thats the portion that latches the mag.
The spring,,flip it upside-down from what it is in the pic,,loop to the top ,,short leg to the front, long leg to the rear.
The larger dia pin will go through the pivot hole in the top of the latch and also the loop in the spring,,the spring inbetween the legs of the latch of course.
The smaller dia pin goes through the lower hole and the larger dia hole in the latch. That allows some limited pivot movement to the latch when removing/inserting the magazine.
The long leg of the spring will bear against the inside rear wall of the backstrap.
The short leg of the spring will push against the latch itself just below where the lower pin is centered.
That gives the latch forward spring tension.
It's difficult to insert the latch and the small spring up into the frame as separate pieces, compressing the spring as you do so and then trying to insert that upper pin.
The easier way is to make a small 'slave pin' for the upper latch hole.
Make out of a nail or piece of wire, ect. You want a close fit, but a simple slip fit,,nothing you need a hammer and punch to put together.Plus the pin should be no longer than the width of the latch. Slightly chamfered ends really help too during assembly.
Holding the latch in hand, place the spring into position correctly (shorter leg against the latch),,then push the slave pin thru the upper hole securing the spring to the latch.
If the loop in the spring is a bit tight, it may take a little help from a hammer and punch to push into position. Don't grind the spring loop bigger.
Now take that assembly with the slave pin in place and flush with the sides of the latch and place it up in to the frame . As you do the longer leg will start to compress as it enters the frame. Ease it into place and try to position it so you can see the end of the slave pin through the frame hole where the pivot pin will go. If you can see all or most of the pin, a pointed slender punch or even a jewelers screwdriver can often be used to push straight through,,knocking the slave pin out and securing the latch and pin into place.
Now take the factory pin and back the punch down in a bit but not all the way so as not to loose the assembly all together and start the pin into place.
Hold some resistance on that punch while driving the pin into place.
Don't work the latch at this point at least the full swing available to it as it may over bend that new spring and break it.
Place the smaller dia, lower pin in place first. That will limit the latch travel. It should now have both enough power and travel to perform it's job.
Take that small slave pin you loving made by hand, label it and put it away in the specialty tools drawer for the next '15 Beretta that walks in the door w/a bad mag latch.
Then sit back and wait for the Brown Truck of Wondefullness to bring you the magazine.