Please understand that I would really like to help you, but this might get frustrating for you, because I need you to explain what problem you're having. I know it seems obvious to you, but I have no idea what you're struggling with.
You assigned a list to B. You can now do whatever you want with B. You can get its length: Length[B]. You can drop the first element: Rest[B]. I don't understand why you think you can't access it.
It might help if I point out that you're doing a lot of pointless stuff in your code. You don't need all of this imperative style initialization and reassignment stuff. Setting z = 0 isn't necessary. B[[2]] extracts the second element of B, but you aren't doing anything with it, so that's a pointless thing to do. If I'm understanding the line with Sum in it, you're just trying to add up the elements of the list. You can do that with Total. Since your B is "hardcoded" to two possible values, then the sum of B's elements is "hardcoded" to two specific values.
On top of that, you're defining Sum2 by first defining a function and then passing the arguments of Sum2 to that function. Why not just define Sum2 directly? Something like this:
Sum2[x_, y_] := If[x == 3, 6 + x + y, 15 + x + y]
If that's not producing the results you want, then please explain what results you're actually trying to get. Then we can show you how to get there.