This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
StringBuffer and StringBuilder do not override equals or hashCode. That means that equals uses only ==. In other words, your two keys are different, and that's why the map has 2 elements.
You try to get it using "1". Even if StringBuffer would have overridden equals to check the contents, you are trying to get the value using a String - an object from a completely different, incompatible class.
As for the get method, assuming the key is not null:
The hash method translates the key's actual hashCode, to "[defend] against poor quality hash functions" (quoted from its Javadoc). The indexFor method translates that in the bucket number. A bucket is a collection of objects which are grouped together. For HashMap that's based on the hash codes. The "table" field is the actual collection of buckets, as an Entry (with Entry being an inner class). This Entry class is actually a form of singly linked list, representing the bucket.
The for-loop checks each Entry to see if the key matches. If it does, that's the right Entry and its value is returned. If not the next Entry is checked until there are no more, in which case null is returned.
StringBuffer is not suited to be used for the keys in a HashMap. The objects that you use for the keys should be immutable. If you use objects that are mutable and the hashcode of the object changes while it's in the map as a key, then the map will get confused and you can get strange things, such as seeing an entry when you iterate over the map, but when you get() it, it isn't there.