This question has been answered in the comments. The former is the fibered product and the latter is the Weil restriction. The former always exists, but the latter does not. I am reposting this as a CW answer so that this question will not reappear on the front page.