The for loops that you did are a good approach, but like you say this will become impractical as the length of the vector gets larger. General solution, for the second example:
a = nchoosek(1:t+n-1,n-1)
b = [zeros(s,1) a (t+n)*ones(s,1)]
Comment: In the second example, you are looking for a vector with 3 values, each value >=0, and the values sum to 3. Suppose the problem is altered temporarily by adding 1 to each value. So now each value is >=1, and the values sum to 6.
Consider a vector of 7 elements, values 0 through 6. Divide the vector into three sections, using two nonidentical movable 'marker' elements that do not include the end points. Here the moveable markers are two elements out of the set of values 1 through 5, and the function nchoosek(1:5,2) give a list of all possible choices. An example is
Two stationary lines have been added at the end points. Now as the m's move around, the distances between the marker lines are the 3 values you need. These distances have minimum value 1 and add to 6. Subtracting 1 from all three distances gets back to the original problem.