It's a language design philosophy.
Some languages are designed to make it easy for the compiler to check that all structure and class accesses are correct. They require all the members to be declared ahead of time, and you can't change the structure of objects. This makes programs less flexible, but catches many types of errors when compiling. C and C++ are like this.
Other languages are designed with flexibility in mind, as well as allowing incremental development in an interpreter. They use dynamic data structures for objects, and allow you to define new methods at run time. The cost paid for this flexibility is that some errors that could have been detected by the compiler in C-style languages can only be detected when you run the program (and some of them may even go undetected). Javascript and Lisp are examples of this.
And some languages are somewhere in between. PHP allows you to add properties to classes, but I don't think you can add methods on the fly.