The MIT license is considered a fairly permissive license for a number of reasons, including the sublicense clause:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Emphasis mine
It's this portion of the MIT license that allows anyone to take an MIT license and re-license so long as they maintain the requirements stated with The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Is it legal for the author to change the license from MIT license to a commercial one, if he is the only contributor?
Yes, as the sole author of the project, they own the copyright to the project. Owning the copyright allows them to re-license the project to a commercial license.
In this particular case, the copyright owner to the project can re-license as they wish and does not need to maintain the copyright or permission notices from the MIT license.
Is it legal to change the license from MIT license to a commercial one, if there are other contributors involved?
The project could be re-licensed in any of the following cases:
- If the other contributors assigned their copyright to the project or the original author.
- If the other contributors didn't assign copyright but they all agreed to the re-license.
- Someone chooses to exercise the sublicense clause of the MIT license that the project was released under.
In the first two cases, the copyright owner(s) can re-license without maintaining the copyright and permission notices.
In the third case, the person re-licensing the project must obey the terms of the license and they must maintain the copyright and permission notices.
Also note that the MIT license is not a copyleft license, so there is no obligation to share the associated source code.
Likewise, just because someone chooses to fork and re-license a project, that re-licensing applies only to the forked project. The re-licensing has no bearing upon the original project or how the original project is licensed.