Why are these two code snippets not equal? (One throws error)

This works just fine:
(Assume that b is declared as a GameObject and defined and that BulletBehavior is a valid script).

var s = b.GetComponent(BulletBehavior);
s.Damage = Damage;

This does not:

var s;
s = b.GetComponent(BulletBehavior);
s.Damage = Damage;

And throws an error that Damage is not a member of Object.

I just want to know why.

They are different because in the first code fragment the compiler infers that variable s is of type BulletBehavior which it can do as it is defined and set at the same time. In the second case you are declaring a generic s variable and then assigning a BulletBehaviour to it. So the compiler in the second example has no idea what the properties or methods of the variable s are.

The second version would work if you did this:

  var s: BulletBehavior;
  s = b.GetComponent(BulletBehavior);

You should avoid open generic variables and also define #pragma strict at the top of each file.