Here's how to do it in Photoshop:
1. Select the Magic Wand tool.
Depending on the quality of the image, you may have to play around with the tolerance (can be found along the top of the window) to have the wand select the color you want. 0 tolerance means that the wand will select only that specific color with no wiggle room for other shades. 30 will probably be a good starting level.
2. Using the Magic Wand, select a shape.
3. Cut, using Ctrl+x (Command+x on Mac).
The shape will disappear, leaving a hole in your image.
4. Paste in place using Ctrl+Shift+x (or Command+Shift+x)
This will create a new layer with your shape.
5. Repeat for each shape.
6. Hide all shapes, fill in the holes with eye-dropper.
If you need the background to be one solid color without those holes where your shapes used to be, use the wand to select the holes and fill them with the eyedropper.
This will work best if your colors are truly uniform and solid, otherwise it might be hard to get well-defined edges. What you want is a pretty basic thing so most other graphics editors will be able to do this with a similar process. If you wanted an automatic process that does all of that automatically, I don't know if I have the answer. Illustrator's image-trace would be the closest thing that I could think of, but even then you'd have to separate each part into layers and fill in the gaps.