Stack and heap buffer overflows are essentially caused by writing a lot of data into a region of memory that is too small to contain all of the data - causing the data to be written beyond the extent of the allocation and blatting whatever sits after it logically in memory. In the case of a stack-overflow this may be a return address for the function and in the case of the a heap overflow this may include virtual function pointers from other C++ objects on the heap. In either case, an attacker may be able to use the vulnerability to take control of the process when the overwritten function returns or the overwritten heap object is used.
If you are a web-developer, the most important class of vulnerabilities that you need to look at are SQL-injections and problems caused by inappropriate include/eval/file-writes in the server code which might allow a string or file passed by a user to eventually be treated as code on the server. Unfortunately for web-developers, these types of attacks tend to be much more effective and are much easier to do than buffer-overflow attacks on native code, and consequently the impact of not fully understanding security as a web-developer can be much more painful than not understanding security as a native developer.