To dream that you are masturbating represents your unacknowledged and unexpressed sexual needs/desires. It may also indicate you need to take care of yourself in sensual or emotional ways which are not necessarily sexual. Or perhaps, you may need to put forth a little more effort toward some relationship.
To see others masturbating in your dreams denotes your anxieties and concerns about your inhibitions. It may also be a reflection that something in your waking life is not as satisfying as it could be. Keep in mind that this dream may not necessarily represent sexual inhibitions or satisfaction, but may be analogous to some situation or relationship.