If you are part of an agency shop, you are required to pay union dues and fees, but you are not required to have an actual membership in the union. So you can choose not to be an official member of the union, but you still have to pay dues as though you are a member. The dues you pay, however, only cover the costs of activities related to collective bargaining, contract administration and grievance adjustment, and not other items such as organizing and political activity.
If you object to your dues being spent on a particular purpose, you have the right to object until it is determined whether the money being spent is used for activity related to representing you in bargaining with the employer. Under a 1988 US Supreme Court decision known as Beck, unions cannot force non-members to pay a full agency fee if any portion is used to pay the costs of union political activities. As a result, unions may be required to calculate that percent of their total budget allocated to political activities, and refund that portion of your agency fee (which may be very small).
If you pay agency fees, the union, in return, must represent you in negotiations with the employer, as in an open shop bargaining unit. However, the union's duties end there - if you are not an official member then you do not receive the broader protections, such as disciplinary processes, included in union contracts. This arrangement is legal as long as your state has not passed a right to work law. Most examples of these types of shops are public sector unions including teachers unions.