Most operating systems have built-in firewall software. OS X allows incoming Screen Sharing connections by default. Windows allows incoming connections on port 3389 automatically while RDP is enabled in system preferences, but might require an additional configuration for VNC servers.
Here are the instructions on how to make Windows firewall accept incoming VNC/RDP connections.
If your computer is running a third-party firewall software, please refer to its documentation for information.