Why the 2nd always block works is coz, its no longer a clocked sequential block, but a combinational block. The output follows the input whenever there's a change in the input.
Try with a clock and reset, and also as Cris72 mentioned, check Pin assignments, use [15:0] instead of integers. Try the following code and check:
module encoder (
clock,
reset, // Its good to use a reset so that Flops are set to a known state.
enc_out
);
input clock;
input reset;
output enc_out;
reg enc_out;
reg count;
always @(posedge clock or negedge reset) begin
if(!reset) begin
count <= 16'd0;
end
else begin
count <= count + 16'd1;
end
end
always @ (count) begin
if (count ==16'd50000)
enc_out <= 1'b0;
else if (count < 16'd25000)
enc_out <= 1'b1;
else
enc_out <= 1'b0;
end
endmodule