We use wealth by level as a guideline for placing loot, but the rule with magic items is you get what you get. A character could, at any given moment, be over or undergeared for their level based on their performance and luck.
Characters, obviously, are allowed to keep all loot they acquire over the course of an adventure. Magic Items acquired this way can be handled one of various of ways:
1) the item can be sold to a generic vendor (aka Rifikki) for 1/2 Fair Market Value (FMV), with revenue divided amongst PCs from that adventure
2) The item can be sold to another PC for an agreed upon price between the two PC involved with the revenue divided amongst PCs from that adventure
3) I (Rifikki), can roll % one time for you to see if a random adventurer wants to buy it off you, for an amount agreed upon by you and I. This % is as low as 5% for odd or exotic to a max of 20% for common magic items.
Mundane/alchemical/masterwork items if not sold to another PC ate simply sold for 1/2 FMV.
Additionally, random magic items will occasionally be made for sale in the Gameplay thread, where characters with sufficient gold can buy them (on a first come, first served basis). Your character can still make such purchases while still in an encounter, but they do not get access to them until they are between encounters.
Finally crafting is available and highly encouraged. Enterprising PCs could make a mint making custom magic items to order for other PCs.