The MIT license reads as follows.
> Permission is hereby granted... to deal in the Software without restriction, including without limitation the rights to... sublicense
Because you have the right to "sublicense", you can take MIT code and license it under another license (GPL) even though you are not the copyright holder.
The BSD license is less clear on this point (in fact this is one of the important differences) and whether the BSD's grant includes the right of sublicense is more debatable, but in my view the answer is "probably".
I am not a lawyer; I am not your lawyer; this is not legal advice.